MCPcopy Create free account
hub / github.com/DescentDevelopers/Descent3 / PlayerGetBallPosition

Function PlayerGetBallPosition

Descent3/Player.cpp:3394–3421  ·  view source on GitHub ↗

Gets the position of a given ball in world coords

Source from the content-addressed store, hash-verified

3392
3393// Gets the position of a given ball in world coords
3394void PlayerGetBallPosition(vector *dest, int slot, int num) {
3395 matrix rotmat, tempm;
3396 object *obj = &Objects[Players[slot].objnum];
3397
3398 // Get position in circle
3399 float ballspeed = Players[slot].ballspeed * 65536;
3400 float rot_temp = ballspeed / 65536.0;
3401 int int_game = Gametime / rot_temp;
3402 float diff = Gametime - (int_game * rot_temp);
3403 int rot_angle = (diff * 65536);
3404 rot_angle = (rot_angle + (num * 5000)) % 65536;
3405
3406 // Get matrix to multiply with
3407 if (num == 0)
3408 vm_AnglesToMatrix(&rotmat, 0, 0, rot_angle);
3409 else if (num == 1)
3410 vm_AnglesToMatrix(&rotmat, 0, rot_angle, 0);
3411 else
3412 vm_AnglesToMatrix(&rotmat, rot_angle, 0, 0);
3413
3414 tempm = obj->orient * rotmat;
3415
3416 // Get world position
3417 if (num == 1)
3418 *dest = obj->pos + (tempm.fvec * (obj->size + 1));
3419 else
3420 *dest = obj->pos + (tempm.uvec * (obj->size + 1));
3421}
3422
3423// Sets a wacky rotating ball around the player ship
3424void PlayerSetRotatingBall(int slot, int num, float speed, float *r, float *g, float *b) {

Callers 2

DrawPlayerRotatingBallFunction · 0.85
DoObjectLightFunction · 0.85

Calls 1

vm_AnglesToMatrixFunction · 0.50

Tested by

no test coverage detected