#include "part.h" #include "physics/util.h" Part::Part(): BasePart(&TYPE) { } Part::Part(PartConstructParams params): BasePart(&TYPE, params) { } void Part::updateCollider(rp::PhysicsCommon* common) { rp::BoxShape* shape = common->createBoxShape(glmToRp(size * glm::vec3(0.5f))); // Recreate the rigidbody if the shape changes if (rigidBody->getNbColliders() > 0 && dynamic_cast(rigidBody->getCollider(0)->getCollisionShape())->getHalfExtents() != shape->getHalfExtents()) { // TODO: This causes Touched to get called twice. Fix this. rigidBody->removeCollider(rigidBody->getCollider(0)); rigidBody->addCollider(shape, rp::Transform()); } if (rigidBody->getNbColliders() == 0) rigidBody->addCollider(shape, rp::Transform()); }