MCPcopy Create free account
hub / github.com/GarageGames/Torque3D / processTick

Method processTick

Engine/source/T3D/physics/physicsForce.cpp:152–192  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

150}
151
152void PhysicsForce::processTick( const Move * )
153{
154 if ( isMounted() )
155 {
156 MatrixF test( true );
157 test.setPosition( Point3F( 0, 4, 0 ) );
158 AssertFatal( test != mMount.xfm, "Error!" );
159
160 MatrixF mat( true );
161 mMount.object->getMountTransform( mMount.node, mMount.xfm, &mat );
162 setTransform( mat );
163 }
164
165 // Nothing to do without a body or if physics hasn't ticked.
166 if ( !mBody || !mPhysicsTick )
167 return;
168
169 mPhysicsTick = false;
170
171 // If we lost the body then release it.
172 if ( !mBody->isDynamic() || !mBody->isSimulationEnabled() )
173 {
174 detach();
175 return;
176 }
177
178 // Get our distance to the body.
179 Point3F cMass = mBody->getCMassPosition();
180 Point3F vector = getPosition() - cMass;
181
182 // Apply the force!
183 F32 mass = mBody->getMass();
184 Point3F impulse = ( mass * vector ) / TickSec;
185
186 // Counter balance the linear impulse.
187 Point3F linVel = mBody->getLinVelocity();
188 Point3F currentForce = linVel * mass;
189
190 // Apply it.
191 mBody->applyImpulse( cMass, impulse - currentForce );
192}
193
194DefineEngineMethod( PhysicsForce, attach, void, ( Point3F start, Point3F direction, F32 maxDist ),,
195 "@brief Attempts to associate the PhysicsForce with a PhysicsBody.\n\n"

Callers

nothing calls this directly

Calls 9

Point3FClass · 0.70
setPositionMethod · 0.45
getMountTransformMethod · 0.45
isDynamicMethod · 0.45
isSimulationEnabledMethod · 0.45
getCMassPositionMethod · 0.45
getMassMethod · 0.45
getLinVelocityMethod · 0.45
applyImpulseMethod · 0.45

Tested by

no test coverage detected