Removing bone assignments

A place for users of OGRE to discuss ideas and experiences of utilitising OGRE in their games / demos / applications.
Post Reply
Posts: 2
Joined: Sat May 17, 2014 8:04 pm

Removing bone assignments

Post by damian0815 » Thu Sep 04, 2014 10:48 am

Hi all,

Is there any way to remove bone assignments? I'm working on a system to allow parts of a skeletal animated mesh to be controlled by softbody physics (FEM) and I need to be able to clear the bone assignments on the FEM target vertices so that the skeletal animation doesn't put the vertices in a different reference frame to the FEM.

I can't assign all the vertex bone weights to 0 as that causes NaN's for the weights passed to the hardware buffer by _rationaliseBoneAssignments (called by _compileBoneAssignments).

Here's what I have:

Code: Select all

	const set<size_t>& vertexGroup = ...; // set of vertex indices to clear bone assignments
	// loop through all bone assignments and zero the weight
	for ( auto &it: mEntity->getMesh()->getBoneAssignmentIterator() ) {
		size_t vertexIndex = it.first;
		// only clear bone assignments for vertices that are in the vertexGroup
		if ( vertexGroup.count(vertexIndex) {
			Ogre::VertexBoneAssignment& assignment = it.second;
			// hack to avoid NaN when all weights are 0
			assignment.weight = 0.00000001f;
	// (re)-compile the bone assignments
I don't like the hack :( What I really want is to be able to do this:

Code: Select all

	// remove all bone assignments for given vertex

Code: Select all

	// remove bone assignment for given vertex and bone
	mEntity->getMesh()->removeBoneAssignment(ogreVertexIndex, boneIndex); 
Any options I haven't thought of?
0 x

User avatar
OGRE Team Member
OGRE Team Member
Posts: 3996
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 191

Re: Removing bone assignments

Post by dark_sylinc » Mon Sep 08, 2014 8:53 pm

You're right, there's no function provided to remove assignments (except for clearBoneAssignments which removes all of them), and adding the function to the library seems like the best bet.

Keep something in mind: ALL vertices need to be assigned to at least one bone. You can workaround this problem by creating a dummy node with an identity transform and assign the vertex to that bone.
0 x

Post Reply