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

Method getMoveList

Engine/source/T3D/aiClient.cpp:203–381  ·  view source on GitHub ↗

* This method gets the move list for an object, in the case * of the AI, it actually calculates the moves, and then * sends them down the pipe. * * @param movePtr Pointer to move the move list into * @param numMoves Number of moves in the move list */

Source from the content-addressed store, hash-verified

201 * @param numMoves Number of moves in the move list
202 */
203U32 AIClient::getMoveList( Move **movePtr,U32 *numMoves ) {
204 //initialize the move structure and return pointers
205 mMove = NullMove;
206 *movePtr = &mMove;
207 *numMoves = 1;
208
209 // Check if we got a player
210 mPlayer = NULL;
211 mPlayer = dynamic_cast<Player *>( getControlObject() );
212
213 // We got a something controling us?
214 if( !mPlayer )
215 return 1;
216
217
218 // What is The Matrix?
219 MatrixF moveMatrix;
220 moveMatrix.set( EulerF( 0, 0, 0 ) );
221 moveMatrix.setColumn( 3, Point3F( 0, 0, 0 ) );
222 moveMatrix.transpose();
223
224 // Position / rotation variables
225 F32 curYaw, curPitch;
226 F32 newYaw, newPitch;
227 F32 xDiff, yDiff;
228
229
230 F32 moveSpeed = mMoveSpeed;
231
232 switch( mMoveMode ) {
233
234 case ModeStop:
235 return 1; // Stop means no action
236 break;
237
238 case ModeStuck:
239 // Fall through, so we still try to move
240 case ModeMove:
241
242 // Get my location
243 MatrixF const& myTransform = mPlayer->getTransform();
244 myTransform.getColumn( 3, &mLocation );
245
246 // Set rotation variables
247 Point3F rotation = mPlayer->getRotation();
248 Point3F headRotation = mPlayer->getHeadRotation();
249 curYaw = rotation.z;
250 curPitch = headRotation.x;
251 xDiff = mAimLocation.x - mLocation.x;
252 yDiff = mAimLocation.y - mLocation.y;
253
254 // first do Yaw
255 if( !mIsZero( xDiff ) || !mIsZero( yDiff ) ) {
256 // use the cur yaw between -Pi and Pi
257 while( curYaw > M_2PI_F )
258 curYaw -= M_2PI_F;
259 while( curYaw < -M_2PI_F )
260 curYaw += M_2PI_F;

Callers

nothing calls this directly

Calls 15

mIsZeroFunction · 0.85
mAtan2Function · 0.85
mFabsFunction · 0.85
setColumnMethod · 0.80
getColumnMethod · 0.80
mulPMethod · 0.80
Point3FClass · 0.50
Point2FClass · 0.50
setMethod · 0.45
transposeMethod · 0.45
getTransformMethod · 0.45
getRotationMethod · 0.45

Tested by

no test coverage detected