Use of api(CreateFromTriMesh)

Post Reply
water
Posts: 33
Joined: Fri Jun 05, 2020 8:36 am

Use of api(CreateFromTriMesh)

Post by water »

static btSoftBody* CreateFromTriMesh(btSoftBodyWorldInfo& worldInfo,
const btScalar* vertices,
const int* triangles,
int ntriangles,
bool randomizeConstraints = true);
Hello, can you help me explain what these parameters represent and how to obtain them?
const btScalar* vertices,
const int* triangles,
int ntriangles,
thank you very much
User avatar
drleviathan
Posts: 698
Joined: Tue Sep 30, 2014 6:03 pm
Location: San Francisco

Re: Use of api(CreateFromTriMesh)

Post by drleviathan »

You should examine the implementation of btSoftBodyHelpers::CreateFromTriMesh() inside the CPP file to see how they are used. But I would guess:

const btScalar* vertices is a pointer to a buffer of btScalar representing the float or double (depending on if btScaler is a float or double) values the vertices. I would assume (but you can verify by looking at the code) the vertices are in order: xyzxyzxyx..., where each set of three represents a 3D point.

const int* triangles is a pointer to a buffer of int indices representing offsets to points inside the vertices buffer. I would assume (but you can verify by looking at the code) the indices are ordered in sets of three: abcabcabc... where each abc indexes the three points of a triangle.

int ntriangles is "number of triangles". This means the triangles buffer must be 3*ntriangles long. The length of the vertices buffer doesn't matter to the function call: if done correctly the triangles indices should never offset outside of it.

bool randomizeConstraints = true determines if the constraints in the soft body should be solved randomly or systematically. I think: best to leave this true unless you really know how the SoftBody solver works.
water
Posts: 33
Joined: Fri Jun 05, 2020 8:36 am

Re: Use of api(CreateFromTriMesh)

Post by water »

Thank you very much for your reply.

I tried to use btSoftBodyHelpers::CreateFromTriMesh and btSoftBodyHelpers::CreateFromConvexHull to create the softbody but it has been unsuccessful. Could you please tell me why?

Image

m_size=0 and - m_softBodySolver 0x0000000000000000 <NULL> btSoftBodySolver *
User avatar
drleviathan
Posts: 698
Joined: Tue Sep 30, 2014 6:03 pm
Location: San Francisco

Re: Use of api(CreateFromTriMesh)

Post by drleviathan »

I looked at the code for btSoftBody. AFAICT the m_collisionDisabledObjects vector date member of that class is used when linking soft bodies together with "anchors". If you're not doing that then you would expect that vector container to be empty.

The m_bodySolver is set internally, implicitly when adding the body to the world. The code for setting it looks like this:

Code: Select all

        // Set the solver that handles this soft body
        // Should not be allowed to get out of sync with reality
        // Currently called internally on addition to the world
        void setSoftBodySolver(btSoftBodySolver* softBodySolver)
        {
                m_softBodySolver = softBodySolver;
        }
Post Reply