Merge pull request #14932 from AndrewMeadows/allow-kinematic-mesh

Case 21227: don't enforce MOTION_TYPE_STATIC on mesh shapes
This commit is contained in:
Shannon Romano 2019-03-11 15:33:32 -07:00 committed by GitHub
commit c0240d2431
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 32 additions and 51 deletions

View file

@ -1923,11 +1923,6 @@ void EntityItem::setRotation(glm::quat rotation) {
void EntityItem::setVelocity(const glm::vec3& value) {
glm::vec3 velocity = getLocalVelocity();
if (velocity != value) {
if (getShapeType() == SHAPE_TYPE_STATIC_MESH) {
if (velocity != Vectors::ZERO) {
setLocalVelocity(Vectors::ZERO);
}
} else {
float speed = glm::length(value);
if (!glm::isnan(speed)) {
const float MIN_LINEAR_SPEED = 0.001f;
@ -1943,7 +1938,6 @@ void EntityItem::setVelocity(const glm::vec3& value) {
_flags |= Simulation::DIRTY_LINEAR_VELOCITY;
}
}
}
}
void EntityItem::setDamping(float value) {
@ -1959,9 +1953,6 @@ void EntityItem::setDamping(float value) {
void EntityItem::setGravity(const glm::vec3& value) {
withWriteLock([&] {
if (_gravity != value) {
if (getShapeType() == SHAPE_TYPE_STATIC_MESH) {
_gravity = Vectors::ZERO;
} else {
float magnitude = glm::length(value);
if (!glm::isnan(magnitude)) {
const float MAX_ACCELERATION_OF_GRAVITY = 10.0f * 9.8f; // 10g
@ -1973,16 +1964,12 @@ void EntityItem::setGravity(const glm::vec3& value) {
_flags |= Simulation::DIRTY_LINEAR_VELOCITY;
}
}
}
});
}
void EntityItem::setAngularVelocity(const glm::vec3& value) {
glm::vec3 angularVelocity = getLocalAngularVelocity();
if (angularVelocity != value) {
if (getShapeType() == SHAPE_TYPE_STATIC_MESH) {
setLocalAngularVelocity(Vectors::ZERO);
} else {
float speed = glm::length(value);
if (!glm::isnan(speed)) {
const float MIN_ANGULAR_SPEED = 0.0002f;
@ -1998,7 +1985,6 @@ void EntityItem::setAngularVelocity(const glm::vec3& value) {
_flags |= Simulation::DIRTY_ANGULAR_VELOCITY;
}
}
}
}
void EntityItem::setAngularDamping(float value) {

View file

@ -203,11 +203,6 @@ PhysicsMotionType EntityMotionState::computePhysicsMotionType() const {
}
assert(entityTreeIsLocked());
if (_entity->getShapeType() == SHAPE_TYPE_STATIC_MESH
|| (_body && _body->getCollisionShape()->getShapeType() == TRIANGLE_MESH_SHAPE_PROXYTYPE)) {
return MOTION_TYPE_STATIC;
}
if (_entity->getLocked()) {
if (_entity->isMoving()) {
return MOTION_TYPE_KINEMATIC;