Skip to main content
GameDev.net gamedev.net
🔒 Locked 🎮 Unity

Error while executing Mesh.IntersectSubset()

Started by Roembout Oct 15, 2005 at 9:21 AM 1 replies 600+ views
Original Post
Roembout
Roembout
In the fps game I'm building (in C#) I use Mesh.Intersect() to check if the player hits an object or other player when he shoots. To determine the other player is shoot in the head of another body part I'm trying to go a bit further with the collision detection by using Mesh.IntersectSubset() to detect the subset that's bin shot. While executing that method I get a invalid call error: -2005530516 D3DERR_INVALIDCALL at Microsoft.DirectX.Direct3D.Mesh.IntersectSubset(Int32 attributeId, Vector3 rayPos, Vector3 rayDir, IntersectInformation& closestHit, IntersectInformation[]& allHits) at Microsoft.DirectX.Direct3D.Mesh.IntersectSubset(Int32 attributeId, Vector3 rayPos, Vector3 rayDir) The part of my sourcecode where I call IntersecSubset looks like this: // Nearcor = Vector3.Unproject(new Vector3(Xpos, Ypos, 0), viewport, projection, view, Engine.Device3D.Transform.World); Farcor = Vector3.Unproject(new Vector3(Xpos, Ypos, 1), viewport, projection, view, Engine.Device3D.Transform.World); Farcor.Normalize(); if(m_Mesh.IntersectSubset(0, Nearcor, Farcor)) { Console.WriteLine("hit"); } // The Nearcor and Farcor I also use for the Mesh.Intersect() which works fine. I'm beginning to think there's a bug in Mesh.IntersectSubset(). Anybody who has experience with this? Thx in advance.
jollyjeffers
jollyjeffers
Have you tried running with the debug runtimes? (Link in my signiture if you're not familiar with this) they'll usually elaborate on the D3DERR_INVALIDCALL and tell you what it doesn't like about what you've given it [smile]

hth
Jack
<hr align="left" width="25%" />
Jack Hoxley <small>[</small><small> Forum FAQ | Revised FAQ |
Roembout
Roembout
I've found the solution, It seems that the mesh had to be optimized first like this:

int[] adjacency = new int[m_Mesh.NumberFaces * 3];
m_Mesh.GenerateAdjacency(1e-6f, adjacency);
m_Mesh.OptimizeInPlace(MeshFlags.OptimizeVertexCache | MeshFlags.OptimizeAttributeSort | MeshFlags.OptimizeIgnoreVerts, adjacency);

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.