Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Model support for collision meshes #5

Open
walbourn opened this issue Jun 20, 2015 · 2 comments
Open

Model support for collision meshes #5

walbourn opened this issue Jun 20, 2015 · 2 comments

Comments

@walbourn
Copy link
Member

The existing CMO and SDKMESH model loaders create IBs and VBs as USAGE_DEFAULT and then release the loaded geometry. This is a great match for rendering, but makes it difficult to do CPU-side triangle-based collision.

There should be a way to get Model to keep a shadow-copy or a parameter to inform the system that the loaded model is for collision and not intended for rendering...

@walbourn
Copy link
Member Author

D3DX's Mesh Intersect performed the following test.

  • Perform a ray-hit test against the bounding box of the mesh. If it missed, no hits. If it hit, further processing.
  • Allocate an array of Booleans with the same number of entries as the maximum vertex index in the mesh.
  • Generates a plane containing the test ray, and store if the vertex was 'in front' or 'behind' that test plane.
  • For each triangle in the mesh, first check to see if all vertices in the triangle are on the same 'side' of the test plane by looking in that array. If they are, skip testing that triangle because it can't hit the ray.
  • Compute triangle hit test. All hits are stored in an array in sorted order.

@walbourn
Copy link
Member Author

Could support by adding a 'flags' option to Model::CreateFrom* to include collision data in the form of two simple std::vector arrays in ModelMesh.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant