History

Merge pull request #3312 from AndrewMeadows/ragdoll

use dispatchTable for shape-vs-shape collision queries

Andrzej Kapolka committed 12 years ago

Commit e29a4e72 parents 12d641d 7a5c4fd17 files · +409 −574Browse files

Showing the changes to interface/src/avatar/SkeletonModel.cpp (1 of 17 files). Show all

Unified · Split

interface/src/avatar/SkeletonModel.cpp+9−9
@@ -620,19 +620,19 @@ void SkeletonModel::buildShapes() { · 619 unmodified lines
620 Shape::Type type = joint.shapeType;620 Shape::Type type = joint.shapeType;
621 int parentIndex = joint.parentIndex;621 int parentIndex = joint.parentIndex;
622 if (parentIndex == -1 || radius < EPSILON) {622 if (parentIndex == -1 || radius < EPSILON) {
623 type = Shape::UNKNOWN_SHAPE;623 type = UNKNOWN_SHAPE;
624 } else if (type == Shape::CAPSULE_SHAPE && halfHeight < EPSILON) {624 } else if (type == CAPSULE_SHAPE && halfHeight < EPSILON) {
625 // this shape is forced to be a sphere625 // this shape is forced to be a sphere
626 type = Shape::SPHERE_SHAPE;626 type = SPHERE_SHAPE;
627 }627 }
628 Shape* shape = NULL;628 Shape* shape = NULL;
629 if (type == Shape::SPHERE_SHAPE) {629 if (type == SPHERE_SHAPE) {
630 shape = new VerletSphereShape(radius, &(points[i]));630 shape = new VerletSphereShape(radius, &(points[i]));
631 shape->setEntity(this);631 shape->setEntity(this);
632 float mass = massScale * glm::max(MIN_JOINT_MASS, DENSITY_OF_WATER * shape->getVolume());632 float mass = massScale * glm::max(MIN_JOINT_MASS, DENSITY_OF_WATER * shape->getVolume());
633 points[i].setMass(mass);633 points[i].setMass(mass);
634 totalMass += mass;634 totalMass += mass;
635 } else if (type == Shape::CAPSULE_SHAPE) {635 } else if (type == CAPSULE_SHAPE) {
636 assert(parentIndex != -1);636 assert(parentIndex != -1);
637 shape = new VerletCapsuleShape(radius, &(points[parentIndex]), &(points[i]));637 shape = new VerletCapsuleShape(radius, &(points[parentIndex]), &(points[i]));
638 shape->setEntity(this);638 shape->setEntity(this);
@@ -731,7 +731,7 @@ void SkeletonModel::computeBoundingShape(const FBXGeometry& geometry) { · 92 unmodified lines
731 shapeExtents.reset();731 shapeExtents.reset();
732 glm::vec3 localPosition = shape->getTranslation();732 glm::vec3 localPosition = shape->getTranslation();
733 int type = shape->getType();733 int type = shape->getType();
734 if (type == Shape::CAPSULE_SHAPE) {734 if (type == CAPSULE_SHAPE) {
735 // add the two furthest surface points of the capsule735 // add the two furthest surface points of the capsule
736 CapsuleShape* capsule = static_cast<CapsuleShape*>(shape);736 CapsuleShape* capsule = static_cast<CapsuleShape*>(shape);
737 glm::vec3 axis;737 glm::vec3 axis;
@@ -743,7 +743,7 @@ void SkeletonModel::computeBoundingShape(const FBXGeometry& geometry) { · 5 unmodified lines
743 shapeExtents.addPoint(localPosition + axis);743 shapeExtents.addPoint(localPosition + axis);
744 shapeExtents.addPoint(localPosition - axis);744 shapeExtents.addPoint(localPosition - axis);
745 totalExtents.addExtents(shapeExtents);745 totalExtents.addExtents(shapeExtents);
746 } else if (type == Shape::SPHERE_SHAPE) {746 } else if (type == SPHERE_SHAPE) {
747 float radius = shape->getBoundingRadius();747 float radius = shape->getBoundingRadius();
748 glm::vec3 axis = glm::vec3(radius);748 glm::vec3 axis = glm::vec3(radius);
749 shapeExtents.addPoint(localPosition + axis);749 shapeExtents.addPoint(localPosition + axis);
@@ -847,13 +847,13 @@ void SkeletonModel::renderJointCollisionShapes(float alpha) { · 97 unmodified lines
847 847
848 glPushMatrix();848 glPushMatrix();
849 // shapes are stored in simulation-frame but we want position to be model-relative849 // shapes are stored in simulation-frame but we want position to be model-relative
850 if (shape->getType() == Shape::SPHERE_SHAPE) { 850 if (shape->getType() == SPHERE_SHAPE) {
851 glm::vec3 position = shape->getTranslation() - simulationTranslation;851 glm::vec3 position = shape->getTranslation() - simulationTranslation;
852 glTranslatef(position.x, position.y, position.z);852 glTranslatef(position.x, position.y, position.z);
853 // draw a grey sphere at shape position853 // draw a grey sphere at shape position
854 glColor4f(0.75f, 0.75f, 0.75f, alpha);854 glColor4f(0.75f, 0.75f, 0.75f, alpha);
855 glutSolidSphere(shape->getBoundingRadius(), BALL_SUBDIVISIONS, BALL_SUBDIVISIONS);855 glutSolidSphere(shape->getBoundingRadius(), BALL_SUBDIVISIONS, BALL_SUBDIVISIONS);
856 } else if (shape->getType() == Shape::CAPSULE_SHAPE) {856 } else if (shape->getType() == CAPSULE_SHAPE) {
857 CapsuleShape* capsule = static_cast<CapsuleShape*>(shape);857 CapsuleShape* capsule = static_cast<CapsuleShape*>(shape);
858 858
859 // draw a blue sphere at the capsule endpoint 859 // draw a blue sphere at the capsule endpoint

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t