diff --git a/interface/src/avatar/MyAvatar.cpp b/interface/src/avatar/MyAvatar.cpp index 8bd3288ee7..403d0596c0 100644 --- a/interface/src/avatar/MyAvatar.cpp +++ b/interface/src/avatar/MyAvatar.cpp @@ -1245,7 +1245,7 @@ void MyAvatar::updateCollisionWithVoxels(float deltaTime, float radius) { float capsuleHalfHeight = boundingShape.getHalfHeight(); const float MAX_STEP_HEIGHT = capsuleRadius + capsuleHalfHeight; const float MIN_STEP_HEIGHT = 0.0f; - glm::vec3 footBase = boundingShape.getPosition() - (capsuleRadius + capsuleHalfHeight) * _worldUpDirection; + glm::vec3 footBase = boundingShape.getCenter() - (capsuleRadius + capsuleHalfHeight) * _worldUpDirection; float highestStep = 0.0f; float lowestStep = MAX_STEP_HEIGHT; glm::vec3 floorPoint; @@ -1262,7 +1262,7 @@ void MyAvatar::updateCollisionWithVoxels(float deltaTime, float radius) { if (horizontalDepth > capsuleRadius || fabsf(verticalDepth) > MAX_STEP_HEIGHT) { isTrapped = true; if (_trapDuration > MAX_TRAP_PERIOD) { - float distance = glm::dot(boundingShape.getPosition() - cubeCenter, _worldUpDirection); + float distance = glm::dot(boundingShape.getCenter() - cubeCenter, _worldUpDirection); if (distance < 0.0f) { distance = fabsf(distance) + 0.5f * cubeSide; } diff --git a/interface/src/renderer/Model.cpp b/interface/src/renderer/Model.cpp index 6bd04d18cf..c0ed002b69 100644 --- a/interface/src/renderer/Model.cpp +++ b/interface/src/renderer/Model.cpp @@ -924,7 +924,7 @@ void Model::computeBoundingShape(const FBXGeometry& geometry) { const FBXJoint& joint = geometry.joints[i]; glm::vec3 jointToShapeOffset = uniformScale * (finalRotations[i] * joint.shapePosition); glm::vec3 localPosition = extractTranslation(transforms[i]) + jointToShapeOffset; - shape->setPosition(localPosition); + shape->setCenter(localPosition); shape->setRotation(finalRotations[i] * joint.shapeRotation); float distance = glm::length(localPosition) + shape->getBoundingRadius(); if (distance > _boundingRadius) { @@ -943,7 +943,7 @@ void Model::computeBoundingShape(const FBXGeometry& geometry) { } Extents shapeExtents; shapeExtents.reset(); - glm::vec3 localPosition = shape->getPosition(); + glm::vec3 localPosition = shape->getCenter(); int type = shape->getType(); if (type == Shape::CAPSULE_SHAPE) { // add the two furthest surface points of the capsule @@ -998,11 +998,11 @@ void Model::resetShapePositions() { for (int i = 0; i < _jointShapes.size(); i++) { Shape* shape = _jointShapes[i]; if (shape) { - shape->setPosition(_translation + _rotation * shape->getPosition()); + shape->setCenter(_translation + _rotation * shape->getCenter()); shape->setRotation(_rotation * shape->getRotation()); } } - _boundingShape.setPosition(_translation + _rotation * _boundingShapeLocalOffset); + _boundingShape.setCenter(_translation + _rotation * _boundingShapeLocalOffset); _boundingShape.setRotation(_rotation); } @@ -1020,7 +1020,7 @@ void Model::updateShapePositions() { glm::vec3 worldPosition = _translation + _rotation * (state.getPosition() + shapeOffset); Shape* shape = _jointShapes[i]; if (shape) { - shape->setPosition(worldPosition); + shape->setCenter(worldPosition); shape->setRotation(_rotation * stateRotation * joint.shapeRotation); float distance = glm::distance(worldPosition, _translation) + shape->getBoundingRadius(); if (distance > _boundingRadius) { @@ -1032,7 +1032,7 @@ void Model::updateShapePositions() { } } _shapesAreDirty = false; - _boundingShape.setPosition(rootPosition + _rotation * _boundingShapeLocalOffset); + _boundingShape.setCenter(rootPosition + _rotation * _boundingShapeLocalOffset); _boundingShape.setRotation(_rotation); } } @@ -1436,7 +1436,7 @@ void Model::renderJointCollisionShapes(float alpha) { glPushMatrix(); if (shape->getType() == Shape::SPHERE_SHAPE) { // shapes are stored in world-frame, so we have to transform into model frame - glm::vec3 position = shape->getPosition() - _translation; + glm::vec3 position = shape->getCenter() - _translation; glTranslatef(position.x, position.y, position.z); const glm::quat& rotation = shape->getRotation(); glm::vec3 axis = glm::axis(rotation); diff --git a/libraries/octree/src/Octree.cpp b/libraries/octree/src/Octree.cpp index cbdc4753dc..f43921e0d1 100644 --- a/libraries/octree/src/Octree.cpp +++ b/libraries/octree/src/Octree.cpp @@ -757,7 +757,7 @@ bool findShapeCollisionsOp(OctreeElement* element, void* extraData) { // coarse check against bounds AACube cube = element->getAACube(); cube.scale(TREE_SCALE); - if (!cube.expandedContains(args->shape->getPosition(), args->shape->getBoundingRadius())) { + if (!cube.expandedContains(args->shape->getCenter(), args->shape->getBoundingRadius())) { return false; } if (!element->isLeaf()) { diff --git a/libraries/shared/src/ListShape.cpp b/libraries/shared/src/ListShape.cpp index dcea97826e..162ee111c7 100644 --- a/libraries/shared/src/ListShape.cpp +++ b/libraries/shared/src/ListShape.cpp @@ -14,7 +14,7 @@ // ListShapeEntry void ListShapeEntry::updateTransform(const glm::vec3& rootPosition, const glm::quat& rootRotation) { - _shape->setPosition(rootPosition + rootRotation * _localPosition); + _shape->setCenter(rootPosition + rootRotation * _localPosition); _shape->setRotation(_localRotation * rootRotation); } @@ -26,7 +26,7 @@ ListShape::~ListShape() { void ListShape::setPosition(const glm::vec3& position) { _subShapeTransformsAreDirty = true; - Shape::setPosition(position); + Shape::setCenter(position); } void ListShape::setRotation(const glm::quat& rotation) { diff --git a/libraries/shared/src/ListShape.h b/libraries/shared/src/ListShape.h index 7ba2410a23..87464779ce 100644 --- a/libraries/shared/src/ListShape.h +++ b/libraries/shared/src/ListShape.h @@ -43,6 +43,7 @@ public: ~ListShape(); void setPosition(const glm::vec3& position); + glm::vec3 getPosition() const { return _position; } void setRotation(const glm::quat& rotation); const Shape* getSubShape(int index) const; diff --git a/libraries/shared/src/Ragdoll.cpp b/libraries/shared/src/Ragdoll.cpp index ee67f94b10..61e90fa39c 100644 --- a/libraries/shared/src/Ragdoll.cpp +++ b/libraries/shared/src/Ragdoll.cpp @@ -76,7 +76,7 @@ void DistanceConstraint::updateProxyShape(Shape* shape, const glm::quat& rotatio case Shape::SPHERE_SHAPE: { // sphere collides at endPoint SphereShape* sphere = static_cast(shape); - sphere->setPosition(translation + rotation * (*_points[1])); + sphere->setCenter(translation + rotation * (*_points[1])); } break; case Shape::CAPSULE_SHAPE: { diff --git a/libraries/shared/src/Shape.h b/libraries/shared/src/Shape.h index 7c8a3abc76..f1a36adfb6 100644 --- a/libraries/shared/src/Shape.h +++ b/libraries/shared/src/Shape.h @@ -32,15 +32,18 @@ public: int getType() const { return _type; } float getBoundingRadius() const { return _boundingRadius; } - const glm::vec3& getPosition() const { return _position; } +// const glm::vec3& getPosition() const { return _position; } const glm::quat& getRotation() const { return _rotation; } - virtual void setPosition(const glm::vec3& position) { _position = position; } +// virtual void setPosition(const glm::vec3& position) { _position = position; } virtual void setRotation(const glm::quat& rotation) { _rotation = rotation; } void setEntity(PhysicalEntity* entity) { _owningEntity = entity; } PhysicalEntity* getEntity() const { return _owningEntity; } + virtual void setCenter(const glm::vec3& center) { _position = center; } + virtual glm::vec3 getCenter() const { return _position; } + protected: // these ctors are protected (used by derived classes only) Shape(Type type) : _type(type), _owningEntity(NULL), _boundingRadius(0.f), _position(0.f), _rotation() {} diff --git a/libraries/shared/src/ShapeCollider.cpp b/libraries/shared/src/ShapeCollider.cpp index f29be3d00e..83105bb6bf 100644 --- a/libraries/shared/src/ShapeCollider.cpp +++ b/libraries/shared/src/ShapeCollider.cpp @@ -157,7 +157,7 @@ bool collideShapeWithAACube(const Shape* shapeA, const glm::vec3& cubeCenter, fl } bool sphereSphere(const SphereShape* sphereA, const SphereShape* sphereB, CollisionList& collisions) { - glm::vec3 BA = sphereB->getPosition() - sphereA->getPosition(); + glm::vec3 BA = sphereB->getCenter() - sphereA->getCenter(); float distanceSquared = glm::dot(BA, BA); float totalRadius = sphereA->getRadius() + sphereB->getRadius(); if (distanceSquared < totalRadius * totalRadius) { @@ -175,7 +175,7 @@ bool sphereSphere(const SphereShape* sphereA, const SphereShape* sphereB, Collis if (collision) { collision->_penetration = BA * (totalRadius - distance); // contactPoint is on surface of A - collision->_contactPoint = sphereA->getPosition() + sphereA->getRadius() * BA; + collision->_contactPoint = sphereA->getCenter() + sphereA->getRadius() * BA; collision->_shapeA = sphereA; collision->_shapeB = sphereB; return true; @@ -186,7 +186,7 @@ bool sphereSphere(const SphereShape* sphereA, const SphereShape* sphereB, Collis bool sphereCapsule(const SphereShape* sphereA, const CapsuleShape* capsuleB, CollisionList& collisions) { // find sphereA's closest approach to axis of capsuleB - glm::vec3 BA = capsuleB->getPosition() - sphereA->getPosition(); + glm::vec3 BA = capsuleB->getCenter() - sphereA->getCenter(); glm::vec3 capsuleAxis; capsuleB->computeNormalizedAxis(capsuleAxis); float axialDistance = - glm::dot(BA, capsuleAxis); @@ -221,7 +221,7 @@ bool sphereCapsule(const SphereShape* sphereA, const CapsuleShape* capsuleB, Col // penetration points from A into B collision->_penetration = (totalRadius - radialDistance) * radialAxis; // points from A into B // contactPoint is on surface of sphereA - collision->_contactPoint = sphereA->getPosition() + sphereA->getRadius() * radialAxis; + collision->_contactPoint = sphereA->getCenter() + sphereA->getRadius() * radialAxis; collision->_shapeA = sphereA; collision->_shapeB = capsuleB; } else { @@ -244,7 +244,7 @@ bool sphereCapsule(const SphereShape* sphereA, const CapsuleShape* capsuleB, Col float sign = (axialDistance > 0.0f) ? -1.0f : 1.0f; collision->_penetration = (sign * (totalRadius + capsuleB->getHalfHeight() - absAxialDistance)) * capsuleAxis; // contactPoint is on surface of sphereA - collision->_contactPoint = sphereA->getPosition() + (sign * sphereA->getRadius()) * capsuleAxis; + collision->_contactPoint = sphereA->getCenter() + (sign * sphereA->getRadius()) * capsuleAxis; collision->_shapeA = sphereA; collision->_shapeB = capsuleB; } @@ -255,13 +255,13 @@ bool sphereCapsule(const SphereShape* sphereA, const CapsuleShape* capsuleB, Col bool spherePlane(const SphereShape* sphereA, const PlaneShape* planeB, CollisionList& collisions) { glm::vec3 penetration; - if (findSpherePlanePenetration(sphereA->getPosition(), sphereA->getRadius(), planeB->getCoefficients(), penetration)) { + if (findSpherePlanePenetration(sphereA->getCenter(), sphereA->getRadius(), planeB->getCoefficients(), penetration)) { CollisionInfo* collision = collisions.getNewCollision(); if (!collision) { return false; // collision list is full } collision->_penetration = penetration; - collision->_contactPoint = sphereA->getPosition() + sphereA->getRadius() * glm::normalize(penetration); + collision->_contactPoint = sphereA->getCenter() + sphereA->getRadius() * glm::normalize(penetration); collision->_shapeA = sphereA; collision->_shapeB = planeB; return true; @@ -271,7 +271,7 @@ bool spherePlane(const SphereShape* sphereA, const PlaneShape* planeB, Collision bool capsuleSphere(const CapsuleShape* capsuleA, const SphereShape* sphereB, CollisionList& collisions) { // find sphereB's closest approach to axis of capsuleA - glm::vec3 AB = capsuleA->getPosition() - sphereB->getPosition(); + glm::vec3 AB = capsuleA->getCenter() - sphereB->getCenter(); glm::vec3 capsuleAxis; capsuleA->computeNormalizedAxis(capsuleAxis); float axialDistance = - glm::dot(AB, capsuleAxis); @@ -287,14 +287,14 @@ bool capsuleSphere(const CapsuleShape* capsuleA, const SphereShape* sphereB, Col } // closestApproach = point on capsuleA's axis that is closest to sphereB's center - glm::vec3 closestApproach = capsuleA->getPosition() + axialDistance * capsuleAxis; + glm::vec3 closestApproach = capsuleA->getCenter() + axialDistance * capsuleAxis; if (absAxialDistance > capsuleA->getHalfHeight()) { // sphere hits capsule on a cap // --> recompute radialAxis and closestApproach float sign = (axialDistance > 0.0f) ? 1.0f : -1.0f; - closestApproach = capsuleA->getPosition() + (sign * capsuleA->getHalfHeight()) * capsuleAxis; - radialAxis = closestApproach - sphereB->getPosition(); + closestApproach = capsuleA->getCenter() + (sign * capsuleA->getHalfHeight()) * capsuleAxis; + radialAxis = closestApproach - sphereB->getCenter(); radialDistance2 = glm::length2(radialAxis); if (radialDistance2 > totalRadius2) { return false; @@ -349,8 +349,8 @@ bool capsuleCapsule(const CapsuleShape* capsuleA, const CapsuleShape* capsuleB, capsuleA->computeNormalizedAxis(axisA); glm::vec3 axisB; capsuleB->computeNormalizedAxis(axisB); - glm::vec3 centerA = capsuleA->getPosition(); - glm::vec3 centerB = capsuleB->getPosition(); + glm::vec3 centerA = capsuleA->getCenter(); + glm::vec3 centerB = capsuleB->getCenter(); // NOTE: The formula for closest approach between two lines is: // d = [(B - A) . (a - (a.b)b)] / (1 - (a.b)^2) @@ -505,13 +505,13 @@ bool capsulePlane(const CapsuleShape* capsuleA, const PlaneShape* planeB, Collis bool planeSphere(const PlaneShape* planeA, const SphereShape* sphereB, CollisionList& collisions) { glm::vec3 penetration; - if (findSpherePlanePenetration(sphereB->getPosition(), sphereB->getRadius(), planeA->getCoefficients(), penetration)) { + if (findSpherePlanePenetration(sphereB->getCenter(), sphereB->getRadius(), planeA->getCoefficients(), penetration)) { CollisionInfo* collision = collisions.getNewCollision(); if (!collision) { return false; // collision list is full } collision->_penetration = -penetration; - collision->_contactPoint = sphereB->getPosition() + + collision->_contactPoint = sphereB->getCenter() + (sphereB->getRadius() / glm::length(penetration) - 1.0f) * penetration; collision->_shapeA = planeA; collision->_shapeB = sphereB; @@ -803,21 +803,21 @@ bool sphereAACube_StarkAngles(const glm::vec3& sphereCenter, float sphereRadius, */ bool sphereAACube(const SphereShape* sphereA, const glm::vec3& cubeCenter, float cubeSide, CollisionList& collisions) { - return sphereAACube(sphereA->getPosition(), sphereA->getRadius(), cubeCenter, cubeSide, collisions); + return sphereAACube(sphereA->getCenter(), sphereA->getRadius(), cubeCenter, cubeSide, collisions); } bool capsuleAACube(const CapsuleShape* capsuleA, const glm::vec3& cubeCenter, float cubeSide, CollisionList& collisions) { // find nerest approach of capsule line segment to cube glm::vec3 capsuleAxis; capsuleA->computeNormalizedAxis(capsuleAxis); - float offset = glm::dot(cubeCenter - capsuleA->getPosition(), capsuleAxis); + float offset = glm::dot(cubeCenter - capsuleA->getCenter(), capsuleAxis); float halfHeight = capsuleA->getHalfHeight(); if (offset > halfHeight) { offset = halfHeight; } else if (offset < -halfHeight) { offset = -halfHeight; } - glm::vec3 nearestApproach = capsuleA->getPosition() + offset * capsuleAxis; + glm::vec3 nearestApproach = capsuleA->getCenter() + offset * capsuleAxis; // collide nearest approach like a sphere at that point return sphereAACube(nearestApproach, capsuleA->getRadius(), cubeCenter, cubeSide, collisions); } diff --git a/libraries/shared/src/SimulationEngine.cpp b/libraries/shared/src/SimulationEngine.cpp index cf3baebec0..d1f773eee7 100644 --- a/libraries/shared/src/SimulationEngine.cpp +++ b/libraries/shared/src/SimulationEngine.cpp @@ -75,7 +75,7 @@ void SimulationEngine::stepForward(float deltaTime, float minError, int maxItera int numDolls = _dolls.size(); for (int i = 0; i < numDolls; ++i) { - // TODO: need to implement: + // TODO: Andrew need to implement: // (1) joints pull points (SpecialCapsuleShape would help solve this) // (2) points slam shapes (SpecialCapsuleShape would help solve this) // (3) shapes collide with pairwise collision bypass diff --git a/tests/physics/src/ShapeColliderTests.cpp b/tests/physics/src/ShapeColliderTests.cpp index 7b3d956065..fc1ad59925 100644 --- a/tests/physics/src/ShapeColliderTests.cpp +++ b/tests/physics/src/ShapeColliderTests.cpp @@ -122,8 +122,8 @@ void ShapeColliderTests::sphereTouchesSphere() { } // contactPoint is on surface of sphereA - glm::vec3 AtoB = sphereB.getPosition() - sphereA.getPosition(); - glm::vec3 expectedContactPoint = sphereA.getPosition() + radiusA * glm::normalize(AtoB); + glm::vec3 AtoB = sphereB.getCenter() - sphereA.getCenter(); + glm::vec3 expectedContactPoint = sphereA.getCenter() + radiusA * glm::normalize(AtoB); inaccuracy = glm::length(collision->_contactPoint - expectedContactPoint); if (fabs(inaccuracy) > EPSILON) { std::cout << __FILE__ << ":" << __LINE__ @@ -152,8 +152,8 @@ void ShapeColliderTests::sphereTouchesSphere() { } // contactPoint is on surface of sphereA - glm::vec3 BtoA = sphereA.getPosition() - sphereB.getPosition(); - glm::vec3 expectedContactPoint = sphereB.getPosition() + radiusB * glm::normalize(BtoA); + glm::vec3 BtoA = sphereA.getCenter() - sphereB.getCenter(); + glm::vec3 expectedContactPoint = sphereB.getCenter() + radiusB * glm::normalize(BtoA); inaccuracy = glm::length(collision->_contactPoint - expectedContactPoint); if (fabs(inaccuracy) > EPSILON) { std::cout << __FILE__ << ":" << __LINE__ @@ -181,7 +181,7 @@ void ShapeColliderTests::sphereMissesCapsule() { glm::quat rotation = glm::angleAxis(angle, axis); glm::vec3 translation(15.1f, -27.1f, -38.6f); capsuleB.setRotation(rotation); - capsuleB.setPosition(translation); + capsuleB.setCenter(translation); CollisionList collisions(16); @@ -192,7 +192,7 @@ void ShapeColliderTests::sphereMissesCapsule() { for (int i = 0; i < numberOfSteps; ++i) { // translate sphereA into world-frame glm::vec3 localPosition = localStartPosition + ((float)i * delta) * yAxis; - sphereA.setPosition(rotation * localPosition + translation); + sphereA.setCenter(rotation * localPosition + translation); // sphereA agains capsuleB if (ShapeCollider::collideShapes(&sphereA, &capsuleB, collisions)) @@ -235,7 +235,7 @@ void ShapeColliderTests::sphereTouchesCapsule() { int numCollisions = 0; { // sphereA collides with capsuleB's cylindrical wall - sphereA.setPosition(radialOffset * xAxis); + sphereA.setCenter(radialOffset * xAxis); if (!ShapeCollider::collideShapes(&sphereA, &capsuleB, collisions)) { @@ -257,7 +257,7 @@ void ShapeColliderTests::sphereTouchesCapsule() { } // contactPoint is on surface of sphereA - glm::vec3 expectedContactPoint = sphereA.getPosition() - radiusA * xAxis; + glm::vec3 expectedContactPoint = sphereA.getCenter() - radiusA * xAxis; inaccuracy = glm::length(collision->_contactPoint - expectedContactPoint); if (fabs(inaccuracy) > EPSILON) { std::cout << __FILE__ << ":" << __LINE__ @@ -286,8 +286,8 @@ void ShapeColliderTests::sphereTouchesCapsule() { } // contactPoint is on surface of capsuleB - glm::vec3 BtoA = sphereA.getPosition() - capsuleB.getPosition(); - glm::vec3 closestApproach = capsuleB.getPosition() + glm::dot(BtoA, yAxis) * yAxis; + glm::vec3 BtoA = sphereA.getCenter() - capsuleB.getCenter(); + glm::vec3 closestApproach = capsuleB.getCenter() + glm::dot(BtoA, yAxis) * yAxis; expectedContactPoint = closestApproach + radiusB * glm::normalize(BtoA - closestApproach); inaccuracy = glm::length(collision->_contactPoint - expectedContactPoint); if (fabs(inaccuracy) > EPSILON) { @@ -298,7 +298,7 @@ void ShapeColliderTests::sphereTouchesCapsule() { } { // sphereA hits end cap at axis glm::vec3 axialOffset = (halfHeightB + alpha * radiusA + beta * radiusB) * yAxis; - sphereA.setPosition(axialOffset * yAxis); + sphereA.setCenter(axialOffset * yAxis); if (!ShapeCollider::collideShapes(&sphereA, &capsuleB, collisions)) { @@ -320,7 +320,7 @@ void ShapeColliderTests::sphereTouchesCapsule() { } // contactPoint is on surface of sphereA - glm::vec3 expectedContactPoint = sphereA.getPosition() - radiusA * yAxis; + glm::vec3 expectedContactPoint = sphereA.getCenter() - radiusA * yAxis; inaccuracy = glm::length(collision->_contactPoint - expectedContactPoint); if (fabs(inaccuracy) > EPSILON) { std::cout << __FILE__ << ":" << __LINE__ @@ -361,7 +361,7 @@ void ShapeColliderTests::sphereTouchesCapsule() { } { // sphereA hits start cap at axis glm::vec3 axialOffset = - (halfHeightB + alpha * radiusA + beta * radiusB) * yAxis; - sphereA.setPosition(axialOffset * yAxis); + sphereA.setCenter(axialOffset * yAxis); if (!ShapeCollider::collideShapes(&sphereA, &capsuleB, collisions)) { @@ -383,7 +383,7 @@ void ShapeColliderTests::sphereTouchesCapsule() { } // contactPoint is on surface of sphereA - glm::vec3 expectedContactPoint = sphereA.getPosition() + radiusA * yAxis; + glm::vec3 expectedContactPoint = sphereA.getCenter() + radiusA * yAxis; inaccuracy = glm::length(collision->_contactPoint - expectedContactPoint); if (fabs(inaccuracy) > EPSILON) { std::cout << __FILE__ << ":" << __LINE__ @@ -445,7 +445,7 @@ void ShapeColliderTests::capsuleMissesCapsule() { CollisionList collisions(16); // side by side - capsuleB.setPosition((1.01f * totalRadius) * xAxis); + capsuleB.setCenter((1.01f * totalRadius) * xAxis); if (ShapeCollider::collideShapes(&capsuleA, &capsuleB, collisions)) { std::cout << __FILE__ << ":" << __LINE__ @@ -460,7 +460,7 @@ void ShapeColliderTests::capsuleMissesCapsule() { } // end to end - capsuleB.setPosition((1.01f * totalHalfLength) * xAxis); + capsuleB.setCenter((1.01f * totalHalfLength) * xAxis); if (ShapeCollider::collideShapes(&capsuleA, &capsuleB, collisions)) { std::cout << __FILE__ << ":" << __LINE__ @@ -477,7 +477,7 @@ void ShapeColliderTests::capsuleMissesCapsule() { // rotate B and move it to the side glm::quat rotation = glm::angleAxis(PI_OVER_TWO, zAxis); capsuleB.setRotation(rotation); - capsuleB.setPosition((1.01f * (totalRadius + capsuleB.getHalfHeight())) * xAxis); + capsuleB.setCenter((1.01f * (totalRadius + capsuleB.getHalfHeight())) * xAxis); if (ShapeCollider::collideShapes(&capsuleA, &capsuleB, collisions)) { std::cout << __FILE__ << ":" << __LINE__ @@ -515,7 +515,7 @@ void ShapeColliderTests::capsuleTouchesCapsule() { int numCollisions = 0; { // side by side - capsuleB.setPosition((0.99f * totalRadius) * xAxis); + capsuleB.setCenter((0.99f * totalRadius) * xAxis); if (!ShapeCollider::collideShapes(&capsuleA, &capsuleB, collisions)) { std::cout << __FILE__ << ":" << __LINE__ @@ -535,7 +535,7 @@ void ShapeColliderTests::capsuleTouchesCapsule() { } { // end to end - capsuleB.setPosition((0.99f * totalHalfLength) * yAxis); + capsuleB.setCenter((0.99f * totalHalfLength) * yAxis); if (!ShapeCollider::collideShapes(&capsuleA, &capsuleB, collisions)) { @@ -558,7 +558,7 @@ void ShapeColliderTests::capsuleTouchesCapsule() { { // rotate B and move it to the side glm::quat rotation = glm::angleAxis(PI_OVER_TWO, zAxis); capsuleB.setRotation(rotation); - capsuleB.setPosition((0.99f * (totalRadius + capsuleB.getHalfHeight())) * xAxis); + capsuleB.setCenter((0.99f * (totalRadius + capsuleB.getHalfHeight())) * xAxis); if (!ShapeCollider::collideShapes(&capsuleA, &capsuleB, collisions)) { @@ -583,7 +583,7 @@ void ShapeColliderTests::capsuleTouchesCapsule() { glm::quat rotation = glm::angleAxis(PI_OVER_TWO, zAxis); capsuleB.setRotation(rotation); glm::vec3 positionB = ((totalRadius + capsuleB.getHalfHeight()) - overlap) * xAxis; - capsuleB.setPosition(positionB); + capsuleB.setCenter(positionB); // capsuleA vs capsuleB if (!ShapeCollider::collideShapes(&capsuleA, &capsuleB, collisions)) @@ -604,7 +604,7 @@ void ShapeColliderTests::capsuleTouchesCapsule() { << " actual = " << collision->_penetration; } - glm::vec3 expectedContactPoint = capsuleA.getPosition() + radiusA * xAxis; + glm::vec3 expectedContactPoint = capsuleA.getCenter() + radiusA * xAxis; inaccuracy = glm::length(collision->_contactPoint - expectedContactPoint); if (fabs(inaccuracy) > EPSILON) { std::cout << __FILE__ << ":" << __LINE__ @@ -632,7 +632,7 @@ void ShapeColliderTests::capsuleTouchesCapsule() { << std::endl; } - expectedContactPoint = capsuleB.getPosition() - (radiusB + halfHeightB) * xAxis; + expectedContactPoint = capsuleB.getCenter() - (radiusB + halfHeightB) * xAxis; inaccuracy = glm::length(collision->_contactPoint - expectedContactPoint); if (fabs(inaccuracy) > EPSILON) { std::cout << __FILE__ << ":" << __LINE__ @@ -648,7 +648,7 @@ void ShapeColliderTests::capsuleTouchesCapsule() { glm::quat rotation = glm::angleAxis(PI_OVER_TWO, zAxis); capsuleB.setRotation(rotation); glm::vec3 positionB = (totalRadius - overlap) * zAxis + shift * yAxis; - capsuleB.setPosition(positionB); + capsuleB.setCenter(positionB); // capsuleA vs capsuleB if (!ShapeCollider::collideShapes(&capsuleA, &capsuleB, collisions)) @@ -670,7 +670,7 @@ void ShapeColliderTests::capsuleTouchesCapsule() { << std::endl; } - glm::vec3 expectedContactPoint = capsuleA.getPosition() + radiusA * zAxis + shift * yAxis; + glm::vec3 expectedContactPoint = capsuleA.getCenter() + radiusA * zAxis + shift * yAxis; inaccuracy = glm::length(collision->_contactPoint - expectedContactPoint); if (fabs(inaccuracy) > EPSILON) { std::cout << __FILE__ << ":" << __LINE__ @@ -707,7 +707,7 @@ void ShapeColliderTests::sphereTouchesAACubeFaces() { float overlap = 0.25f; float sphereOffset = 0.5f * cubeSide + sphereRadius - overlap; sphereCenter = cubeCenter + sphereOffset * axis; - sphere.setPosition(sphereCenter); + sphere.setCenter(sphereCenter); if (!ShapeCollider::sphereAACube(&sphere, cubeCenter, cubeSide, collisions)){ std::cout << __FILE__ << ":" << __LINE__ << " ERROR: sphere should collide with cube. axis = " << axis << std::endl; @@ -740,7 +740,7 @@ void ShapeColliderTests::sphereTouchesAACubeFaces() { float overlap = 1.25f * sphereRadius; float sphereOffset = 0.5f * cubeSide + sphereRadius - overlap; sphereCenter = cubeCenter + sphereOffset * axis; - sphere.setPosition(sphereCenter); + sphere.setCenter(sphereCenter); if (!ShapeCollider::sphereAACube(&sphere, cubeCenter, cubeSide, collisions)){ std::cout << __FILE__ << ":" << __LINE__ << " ERROR: sphere should collide with cube." @@ -814,7 +814,7 @@ void ShapeColliderTests::sphereTouchesAACubeEdges() { float overlap = 0.25f; sphereCenter = cubeCenter + (lengthAxis * 0.5f * cubeSide + sphereRadius - overlap) * axis; - sphere.setPosition(sphereCenter); + sphere.setCenter(sphereCenter); if (!ShapeCollider::sphereAACube(&sphere, cubeCenter, cubeSide, collisions)){ std::cout << __FILE__ << ":" << __LINE__ << " ERROR: sphere should collide with cube. axis = " << axis << std::endl; @@ -856,42 +856,42 @@ void ShapeColliderTests::sphereMissesAACube() { // top sphereCenter = cubeCenter + sphereOffset * yAxis; - sphere.setPosition(sphereCenter); + sphere.setCenter(sphereCenter); if (ShapeCollider::sphereAACube(&sphere, cubeCenter, cubeSide, collisions)){ std::cout << __FILE__ << ":" << __LINE__ << " ERROR: sphere should NOT collide with cube" << std::endl; } // bottom sphereCenter = cubeCenter - sphereOffset * yAxis; - sphere.setPosition(sphereCenter); + sphere.setCenter(sphereCenter); if (ShapeCollider::sphereAACube(&sphere, cubeCenter, cubeSide, collisions)){ std::cout << __FILE__ << ":" << __LINE__ << " ERROR: sphere should NOT collide with cube" << std::endl; } // left sphereCenter = cubeCenter + sphereOffset * xAxis; - sphere.setPosition(sphereCenter); + sphere.setCenter(sphereCenter); if (ShapeCollider::sphereAACube(&sphere, cubeCenter, cubeSide, collisions)){ std::cout << __FILE__ << ":" << __LINE__ << " ERROR: sphere should NOT collide with cube" << std::endl; } // right sphereCenter = cubeCenter - sphereOffset * xAxis; - sphere.setPosition(sphereCenter); + sphere.setCenter(sphereCenter); if (ShapeCollider::sphereAACube(&sphere, cubeCenter, cubeSide, collisions)){ std::cout << __FILE__ << ":" << __LINE__ << " ERROR: sphere should NOT collide with cube" << std::endl; } // forward sphereCenter = cubeCenter + sphereOffset * zAxis; - sphere.setPosition(sphereCenter); + sphere.setCenter(sphereCenter); if (ShapeCollider::sphereAACube(&sphere, cubeCenter, cubeSide, collisions)){ std::cout << __FILE__ << ":" << __LINE__ << " ERROR: sphere should NOT collide with cube" << std::endl; } // back sphereCenter = cubeCenter - sphereOffset * zAxis; - sphere.setPosition(sphereCenter); + sphere.setCenter(sphereCenter); if (ShapeCollider::sphereAACube(&sphere, cubeCenter, cubeSide, collisions)){ std::cout << __FILE__ << ":" << __LINE__ << " ERROR: sphere should NOT collide with cube" << std::endl; }