@@ -28,8 +28,6 @@ public RibbonsLayer(GameBase game)
2828 : base ( game ) {
2929 }
3030
31- internal static readonly float LayerDepth = 0.1f ;
32-
3331 protected override void OnUpdate ( GameTime gameTime ) {
3432 base . OnUpdate ( gameTime ) ;
3533 _camera . UpdateViewMatrix ( ) ;
@@ -113,6 +111,7 @@ protected override void OnDraw(GameTime gameTime, RenderContext context) {
113111 OnStageStatus thisStatus , nextStatus ;
114112 RuntimeNote nextNote ;
115113 NoteMetrics visualNoteMetrics ;
114+ RibbonMeshCreateParams rmcp ;
116115
117116 if ( note . HasNextHold ( ) ) {
118117 thisStatus = NoteAnimationHelper . GetOnStageStatusOf ( note , now , animationMetrics ) ;
@@ -137,7 +136,8 @@ protected override void OnDraw(GameTime gameTime, RenderContext context) {
137136 var ribbonParams = traceCalculator . GetHoldRibbonParameters ( note , nextNote , now , visualNoteMetrics , animationMetrics ) ;
138137
139138 if ( ribbonParams . Visible ) {
140- using ( var mesh = new RibbonMesh ( context . Direct3DDevice , SliceCount , topYRatio , bottomYRatio , z , LayerDepth , new [ ] { ribbonParams } , traceCalculator , now , new [ ] { ( note , note . NextHold ) } , visualNoteMetrics , animationMetrics ) ) {
139+ rmcp = new RibbonMeshCreateParams ( context . Direct3DDevice , SliceCount , topYRatio , bottomYRatio , z , LayerDepth , new [ ] { ribbonParams } , traceCalculator , now , new [ ] { ( note , note . NextHold ) } , visualNoteMetrics , animationMetrics ) ;
140+ using ( var mesh = new RibbonMesh ( rmcp ) ) {
141141 context . DrawRibbon ( mesh , _textureEffect , _ribbonMaterial , _camera . ViewProjectionMatrix , _ribbonTextureSrv ) ;
142142 }
143143
@@ -194,7 +194,8 @@ protected override void OnDraw(GameTime gameTime, RenderContext context) {
194194 }
195195
196196 if ( ribbonParamArray . Any ( rp => rp . Visible ) ) {
197- using ( var mesh = new RibbonMesh ( context . Direct3DDevice , SliceCount , topYRatio , bottomYRatio , z , LayerDepth , ribbonParamArray , traceCalculator , now , flickNotePairs , visualNoteMetrics , animationMetrics ) ) {
197+ rmcp = new RibbonMeshCreateParams ( context . Direct3DDevice , SliceCount , topYRatio , bottomYRatio , z , LayerDepth , ribbonParamArray , traceCalculator , now , flickNotePairs , visualNoteMetrics , animationMetrics ) ;
198+ using ( var mesh = new RibbonMesh ( rmcp ) ) {
198199 context . DrawRibbon ( mesh , _textureEffect , _ribbonMaterial , _camera . ViewProjectionMatrix , _ribbonTextureSrv ) ;
199200 }
200201
@@ -204,7 +205,8 @@ protected override void OnDraw(GameTime gameTime, RenderContext context) {
204205 var ribbonParams = traceCalculator . GetSlideRibbonParameters ( note , nextNote , now , visualNoteMetrics , animationMetrics ) ;
205206
206207 if ( ribbonParams . Visible ) {
207- using ( var mesh = new RibbonMesh ( context . Direct3DDevice , SliceCount , topYRatio , bottomYRatio , z , LayerDepth , new [ ] { ribbonParams } , traceCalculator , now , new [ ] { ( note , note . NextSlide ) } , visualNoteMetrics , animationMetrics ) ) {
208+ rmcp = new RibbonMeshCreateParams ( context . Direct3DDevice , SliceCount , topYRatio , bottomYRatio , z , LayerDepth , new [ ] { ribbonParams } , traceCalculator , now , new [ ] { ( note , note . NextSlide ) } , visualNoteMetrics , animationMetrics ) ;
209+ using ( var mesh = new RibbonMesh ( rmcp ) ) {
208210 context . DrawRibbon ( mesh , _textureEffect , _ribbonMaterial , _camera . ViewProjectionMatrix , _ribbonTextureSrv ) ;
209211 }
210212
@@ -262,7 +264,8 @@ protected override void OnDraw(GameTime gameTime, RenderContext context) {
262264 }
263265
264266 if ( ribbonParamArray . Any ( rp => rp . Visible ) ) {
265- using ( var mesh = new RibbonMesh ( context . Direct3DDevice , SliceCount , topYRatio , bottomYRatio , z , LayerDepth , ribbonParamArray , traceCalculator , now , slideNotePairs , visualNoteMetrics , animationMetrics ) ) {
267+ rmcp = new RibbonMeshCreateParams ( context . Direct3DDevice , SliceCount , topYRatio , bottomYRatio , z , LayerDepth , ribbonParamArray , traceCalculator , now , slideNotePairs , visualNoteMetrics , animationMetrics ) ;
268+ using ( var mesh = new RibbonMesh ( rmcp ) ) {
266269 context . DrawRibbon ( mesh , _textureEffect , _ribbonMaterial , _camera . ViewProjectionMatrix , _ribbonTextureSrv ) ;
267270 }
268271
@@ -272,7 +275,8 @@ protected override void OnDraw(GameTime gameTime, RenderContext context) {
272275 var ribbonParams = traceCalculator . GetSlideRibbonParameters ( note , nextNote , now , visualNoteMetrics , animationMetrics ) ;
273276
274277 if ( ribbonParams . Visible ) {
275- using ( var mesh = new RibbonMesh ( context . Direct3DDevice , SliceCount , topYRatio , bottomYRatio , z , LayerDepth , new [ ] { ribbonParams } , traceCalculator , now , new [ ] { ( note , note . NextSlide ) } , visualNoteMetrics , animationMetrics ) ) {
278+ rmcp = new RibbonMeshCreateParams ( context . Direct3DDevice , SliceCount , topYRatio , bottomYRatio , z , LayerDepth , new [ ] { ribbonParams } , traceCalculator , now , new [ ] { ( note , note . NextSlide ) } , visualNoteMetrics , animationMetrics ) ;
279+ using ( var mesh = new RibbonMesh ( rmcp ) ) {
276280 context . DrawRibbon ( mesh , _textureEffect , _ribbonMaterial , _camera . ViewProjectionMatrix , _ribbonTextureSrv ) ;
277281 }
278282
@@ -295,7 +299,7 @@ protected override void OnGotContext(RenderContext context) {
295299 throw new InvalidOperationException ( ) ;
296300 }
297301
298- _camera = new OrthoCamera ( context . ClientSize . Width , context . ClientSize . Height , - 1 , 1000 ) ;
302+ _camera = new OrthoCamera ( context . ClientSize . Width , context . ClientSize . Height , 0.1f , ViewFrustrumDepth ) ;
299303 var centerPoint = new PointF ( context . ClientSize . Width / 2f , context . ClientSize . Height / 2f ) ;
300304 _camera . Position = new Vector3 ( centerPoint . X , centerPoint . Y , 1 ) ;
301305 _camera . LookAt ( new Vector3 ( centerPoint . X , centerPoint . Y , 0 ) , - Vector3 . UnitY ) ;
@@ -339,6 +343,8 @@ protected override void OnInitialize() {
339343 }
340344
341345 private static readonly int SliceCount = 48 ;
346+ private static readonly float LayerDepth = 1f ;
347+ private static readonly float ViewFrustrumDepth = 100f ;
342348
343349 private OrthoCamera _camera ;
344350
0 commit comments