Cannos wrote:The mesh is definitely not smooth, so this is expected. Due to the triangulation of the banked/curved section it will never be perfectly smooth, though it gets smoother with more dense triangulation. That's probably easier to see in the exaggerated example mesh images rather than in the video where everything is smoothly shaded.
that was what I thought, I have a very similar problem since newton 1.5 with a mesh of a race track that I got from some body, it look really nice but the moment I try to drive a vehicle over it at the curve the vehicle start bumping like crazy just the puck on the video. I ignored and simple did no show the mesh, the years later I try again with another vehicle, this when on version after version until one day to render the normal at the curves and what do yo know the where all bended, not smooth at all, the reason they look nice is because of the magic of normal interpolation for rendering.
one way to show that is not in fact smooth is to render the debug display which show the mesh flat shaded.
try soothing the normal is a good idea by the will required a change in the collision mesh because the engine is designed to have one normal per polygon, so in that regard the physics engine is like a flat shaded renderer.
This is fact a big job that required an entire new collision shape, that passes each triangle with three tringle faces. and the collision resolution does the varicentry normal interpolation. That way the collision will look like a goraud shaded mesh.
has you try rendering the mesh flat shaded to see if this is correct.
if so one quick solution that I can add is an option to the collision tree that smooth edge normal. or maybe smooth vertex normal.
option 3 will only be as good as a high texelated mesh, because you will still have to triangulate the mesh and pass back a normal per triangle.
you can find the inerface you user static collision is this file
../demosSandbox\sdkDemos\demos\UserStaticCollision.cpp
there is a demo for a single infinite plane and one for a height field, to try this
we can do this, see if you can implement the user mesh collision, the try making a height texlaled mesh to see if the problem tend to disappears, if this si the case.
the I can add and a new collision mesh called implicit surface, here the callback report each face with a normal per vertex. and the engine does the interpolation, for collision.
at the moment the triangle have 11 parameters. we can add 3 more for the implicit shape
her is the data structure for the shape.
- Code: Select all
typedef struct NewtonUserMeshCollisionCollideDesc
{
dFloat m_boxP0[4]; // lower bounding box of intersection query in local space
dFloat m_boxP1[4]; // upper bounding box of intersection query in local space
dFloat m_boxDistanceTravel[4]; // max distance that box bpxP0 and boxP1 can travel on this timestep, used this for continue collision mode.
int m_threadNumber; // current thread executing this query
int m_faceCount; // the application should set here how many polygons intersect the query box
int m_vertexStrideInBytes; // the application should set here the size of each vertex
dFloat m_skinThickness; // this is the minimum skin separation specified by the material between these two colliding shapes
void* m_userData; // user data passed to the collision geometry at creation time
NewtonBody* m_objBody; // pointer to the colliding body
NewtonBody* m_polySoupBody; // pointer to the rigid body owner of this collision tree
NewtonCollision* m_objCollision; // collision shape of the colliding body, (no necessarily the collision of m_objBody)
NewtonCollision* m_polySoupCollision; // collision shape of the collision tree, (no necessarily the collision of m_polySoupBody)
dFloat* m_vertex; // the application should set here the pointer to the global vertex of the mesh.
int* m_faceIndexCount; // the application should set here the pointer to the vertex count of each face.
int* m_faceVertexIndex; // the application should set here the pointer index array for each vertex on a face.
// the format of a face is I0, I1, I2, I3, ..., M, N, E0, E1, E2, ..., A
// I0, I1, I2, .. are the indices to the vertex, relative to m_vertex pointer
// M is the index to the material sub shape id
// N in the index to the vertex normal relative to m_vertex pointer
// E0, E1, E2, ... are the indices of the the face normal that is shared to that face edge, when the edge does not share a face normal then the edge index is set to index N, which the index to the face normal
// A is and estimate of the largest diagonal of the face, this used internally as a hint to improve floating point accuracy and algorithm performance.
how is that?