Page 1 of 1

"Point set is degenerate."error

Posted: Thu Mar 08, 2012 6:52 pm
by fredlllll
well i get an argumentexception with this text when i try to make a mobilemesh from a model. the model is just a plane. i uploaded it as attachment(i just added the zip extension. it is not a zip its a normal fbx)

i use this
where origin is just a vector3

Code: Select all

Vector3[] vertices;
                    int[] indices;
                    TriangleMesh.GetVerticesAndIndicesFromModel(model, out vertices, out indices);
                    MobileMesh mm = new MobileMesh(vertices, indices, new BEPUphysics.MathExtensions.AffineTransform(Vector3.One, Quaternion.Identity, origin), BEPUphysics.CollisionShapes.MobileMeshSolidity.Counterclockwise, 10);
if i use this code with another model where it does not crash it does not collide with anything... or im just dumb or the engine does some stuff i dont want it to do

Re: "Point set is degenerate."error

Posted: Thu Mar 08, 2012 9:40 pm
by Norbo
It turns out the MobileMeshShape was using some holdover code which computed a convex hull of the model unnecessarily. A plane has no volume, so the hull generator would throw this exception , but this restriction should not exist for a MobileMeshShape. The development fork contains a fix for the problem. Thanks for the report!
if i use this code with another model where it does not crash it does not collide with anything... or im just dumb or the engine does some stuff i dont want it to do
That sounds like it is a sidedness issue. If the model's winding is clockwise and counterclockwise sidedness is used, objects will pass straight through the surface (though they would have trouble going the other way). Try the opposite sidedness to see if that helps.

By the way, mobile meshes are generally a last resort when no other object type can effectively represent an object. If possible, try to use faster approximations. Examples include CompoundShapes of ConvexHullShapes, CompoundShapes of simple objects (BoxShape, SphereShape, etc.), a single ConvexHullShape, or a single simple object (BoxShape, SphereShape, etc.). If the mesh is an environment that never moves, use a StaticMesh for better performance.

Re: "Point set is degenerate."error

Posted: Thu Mar 08, 2012 9:43 pm
by Norbo
Woops, that 'fix' broke something, one moment :)

Re: "Point set is degenerate."error

Posted: Thu Mar 08, 2012 10:01 pm
by fredlllll
well im using 1.1 atm and when i change the origin thing absolutely nothing happens. the collision stays at the same position.

oh well and i cant use something else. cause i use this for the level. so i make the level mostly in 3dsmax and then have one big model. would a static mesh be faster?

//edit2:
okay i have another model which seems to fuck up the collision >.<
attached it again just with the .zip extension added.
so i use the same stuff as mentioned above. in debug no vertex has Y>0 . this is right. but when i put a sphere on it with the radius 5. the sphere has y=30 so it floats 25 units above. and this looks... well shit

//edit3: its my own dumbness with that 25...

//edit4: okay its not .... im freaking out!!!!

Re: "Point set is degenerate."error

Posted: Thu Mar 08, 2012 10:34 pm
by Norbo
when i change the origin thing absolutely nothing happens. the collision stays at the same position.
Is the entity.Position set later? That would overwrite it. When the mesh is given a transform, the mobile mesh shape constructor 'recenters' the mesh data and outputs a position which the Entity then uses. At the end of construction, the mesh is in the proper location, but the Entity.Position is nonzero.
oh well and i cant use something else. cause i use this for the level. so i make the level mostly in 3dsmax and then have one big model. would a static mesh be faster?
Yes. If your level mesh is static and unmoving, you should use a StaticMesh.

Re: "Point set is degenerate."error

Posted: Thu Mar 08, 2012 10:43 pm
by Norbo
The earlier 'fix' has been fixed and is available on the development fork.

Re: "Point set is degenerate."error

Posted: Thu Mar 08, 2012 10:54 pm
by fredlllll
but im using the world transform of that mobilemesh for drawing the object i used to make the mobile mesh. and it seems that it is offset by y=25 and i dont know where the 25 come from.

Re: "Point set is degenerate."error

Posted: Thu Mar 08, 2012 10:57 pm
by Norbo
It sounds like you're running into recentering. Read this for more information:
http://bepuphysics.codeplex.com/wikipag ... ecentering

Basically, a mesh given to a mobile mesh shape is repositioned into local space around its center of mass. Graphics need to take this recentering into account to render properly.

Re: "Point set is degenerate."error

Posted: Fri Mar 09, 2012 12:03 am
by fredlllll
well i have a dirty workaround now. >.< but well it works for my purposes