@@ -1789,7 +1789,7 @@ public class ShapePrimitive : RenderPrimitive, IDisposable
17891789 protected internal int PrimitiveOffset ;
17901790 protected internal PrimitiveType PrimitiveType ;
17911791
1792- protected readonly VertexBufferBinding [ ] VertexBufferBindings ;
1792+ protected internal readonly VertexBufferBinding [ ] VertexBufferBindings ;
17931793
17941794 public ShapePrimitive ( ) { }
17951795
@@ -1905,7 +1905,6 @@ public class ShapePrimitiveInstances : RenderPrimitive
19051905 public int SubObjectIndex { get ; protected set ; }
19061906
19071907 protected VertexBuffer VertexBuffer ;
1908- protected VertexDeclaration VertexDeclaration ;
19091908 protected int VertexBufferStride ;
19101909 protected IndexBuffer IndexBuffer ;
19111910 protected int PrimitiveCount ;
@@ -1925,7 +1924,6 @@ internal ShapePrimitiveInstances(GraphicsDevice graphicsDevice, ShapePrimitive s
19251924 HierarchyIndex = shapePrimitive . HierarchyIndex ;
19261925 SubObjectIndex = subObjectIndex ;
19271926 VertexBuffer = shapePrimitive . VertexBuffer ;
1928- VertexDeclaration = shapePrimitive . VertexBuffer . VertexDeclaration ;
19291927 IndexBuffer = shapePrimitive . IndexBuffer ;
19301928 PrimitiveCount = shapePrimitive . PrimitiveCount ;
19311929 PrimitiveOffset = shapePrimitive . PrimitiveOffset ;
@@ -1935,7 +1933,25 @@ internal ShapePrimitiveInstances(GraphicsDevice graphicsDevice, ShapePrimitive s
19351933 InstanceBuffer . SetData ( positions ) ;
19361934 InstanceCount = positions . Length ;
19371935
1938- VertexBufferBindings = new [ ] { new VertexBufferBinding ( VertexBuffer ) , new VertexBufferBinding ( InstanceBuffer , 0 , 1 ) } ;
1936+ var instanceBufferBinding = new VertexBufferBinding ( InstanceBuffer , 0 , 1 ) ;
1937+
1938+ if ( VertexBuffer != null )
1939+ {
1940+ VertexBufferBindings = new [ ] { new VertexBufferBinding ( VertexBuffer ) , instanceBufferBinding } ;
1941+ }
1942+ else
1943+ {
1944+ VertexBufferBindings = shapePrimitive . VertexBufferBindings . ToArray ( ) ;
1945+ var dummyInstanceBuffer = RenderPrimitive . GetDummyVertexBuffer ( graphicsDevice ) ;
1946+ var position = - 1 ;
1947+ for ( var i = 0 ; i < VertexBufferBindings . Length ; i ++ )
1948+ if ( VertexBufferBindings [ i ] . VertexBuffer == dummyInstanceBuffer )
1949+ position = i ;
1950+ if ( position == - 1 )
1951+ VertexBufferBindings . Append ( instanceBufferBinding ) ;
1952+ else
1953+ VertexBufferBindings [ position ] = instanceBufferBinding ;
1954+ }
19391955 }
19401956
19411957 public override void Draw ( GraphicsDevice graphicsDevice )
0 commit comments