Пример #1
0
 public void Render(TgcD3dInput input)
 {
     if (VariablesGlobales.debugMode)
     {
         collisionWorld.DebugDrawWorld();
     }
 }
Пример #2
0
 public void OnDrawGizmos()
 {
     if (_doDebugDraw && m_world != null)
     {
         m_world.DebugDrawWorld();
     }
 }
Пример #3
0
        /*
         * protected override void Dispose(bool disposing)
         * {
         *  if (disposing)
         *  {
         *      if (vertexBuffer != null)
         *      {
         *          vertexBuffer.Dispose();
         *          vertexBuffer = null;
         *      }
         *  }
         *
         *  base.Dispose(disposing);
         * }
         */
        public void DrawDebugWorld(CollisionWorld world)
        {
            world.DebugDrawWorld();

            if (lines.Count == 0)
            {
                return;
            }

            inputAssembler.InputLayout = inputLayout;

            if (lineArray.Length != lines.Count)
            {
                lineArray = new PositionColored[lines.Count];
                lines.CopyTo(lineArray);

                if (vertexBuffer != null)
                {
                    vertexBuffer.Dispose();
                }
                vertexBufferDesc.SizeInBytes = PositionColored.Stride * lines.Count;
                using (var data = new DataStream(vertexBufferDesc.SizeInBytes, false, true))
                {
                    data.WriteRange(lineArray);
                    data.Position = 0;
                    vertexBuffer  = new Buffer(device, data, vertexBufferDesc);
                }
                vertexBufferBinding.Buffer = vertexBuffer;
            }
            else
            {
                lines.CopyTo(lineArray);
                using (var map = vertexBuffer.Map(MapMode.WriteDiscard))
                {
                    map.WriteRange(lineArray);
                }
                vertexBuffer.Unmap();
            }

            inputAssembler.SetVertexBuffers(0, vertexBufferBinding);
            inputAssembler.PrimitiveTopology = global::SharpDX.Direct3D.PrimitiveTopology.LineList;

            device.Draw(lines.Count, 0);

            lines.Clear();
        }