Game Development Community

Quick observation on per-object mass.

by Azaezel · in Torque 3D Professional · 12/12/2013 (5:31 pm) · 0 replies

Recently had cause to toss in:
class ShapeBase : public GameBase, public ISceneLight
{
   void setMass( F32 mass );
}

//-----------------------------------------------------------------------------
void ShapeBase::setMass( F32 mass )
 {
	if (mass<0.0001f)
		mass = 0.0001f;
	 mMass = mass;
	 mOneOverMass = 1/mMass;
	 setMaskBits(ScaleMask);
}

DefineEngineMethod( ShapeBase, setMass, void, (F32 mass), ,
				   "Explicitly Sets the mass for a ShapeBase Object Instance. Note: Mass is recalculated based on the stock datablock when objects are mounted.")
{
	object->setMass(mass);
}

Which allows altering any derivation's mass on the fly. An interesting note on that is that it's also recalculated when an object is mounted to the shapebase. Not really sure which one most folks would consider more game-specific, so just throwing it out there.