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

Method processTick

Engine/source/T3D/physics/physicsForce.cpp:154–194  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 10

getPositionFunction · 0.85
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