MCPcopy Create free account
hub / github.com/TombEngine/TombEngine / ModelRigid

Function ModelRigid

TombEngine/Objects/Generic/Object/rope.cpp:494–515  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

492 }
493
494 void ModelRigid(Vector3i* segment, Vector3i* nextSegment, Vector3i* velocity, Vector3i* nextVelocity, int length)
495 {
496 Vector3i vec;
497 vec.x = nextSegment->x + nextVelocity->x - segment->x - velocity->x;
498 vec.y = nextSegment->y + nextVelocity->y - segment->y - velocity->y;
499 vec.z = nextSegment->z + nextVelocity->z - segment->z - velocity->z;
500
501 int result = (65536 * sqrt(abs(pow(vec.x >> FP_SHIFT, 2) + pow(vec.y >> FP_SHIFT, 2) + pow(vec.z >> FP_SHIFT, 2))) - length) / 2;
502 NormaliseRopeVector(&vec);
503
504 vec.x = (int64_t)result * vec.x >> FP_SHIFT;
505 vec.y = (int64_t)result * vec.y >> FP_SHIFT;
506 vec.z = (int64_t)result * vec.z >> FP_SHIFT;
507
508 velocity->x += vec.x;
509 velocity->y += vec.y;
510 velocity->z += vec.z;
511
512 nextVelocity->x -= vec.x;
513 nextVelocity->y -= vec.y;
514 nextVelocity->z -= vec.z;
515 }
516
517 void UpdateRopeSwing(ItemInfo* item)
518 {

Callers 1

RopeDynamicsFunction · 0.85

Calls 1

NormaliseRopeVectorFunction · 0.85

Tested by

no test coverage detected