mirror of
https://github.com/lubosz/overte.git
synced 2025-08-07 16:41:02 +02:00
prevent incompatible entity properties combos
This commit is contained in:
parent
4c9ec7ca43
commit
702e83ba6a
1 changed files with 34 additions and 16 deletions
|
@ -1602,14 +1602,20 @@ void EntityItem::updateMass(float mass) {
|
||||||
void EntityItem::updateVelocity(const glm::vec3& value) {
|
void EntityItem::updateVelocity(const glm::vec3& value) {
|
||||||
glm::vec3 velocity = getLocalVelocity();
|
glm::vec3 velocity = getLocalVelocity();
|
||||||
if (velocity != value) {
|
if (velocity != value) {
|
||||||
const float MIN_LINEAR_SPEED = 0.001f;
|
if (getShapeType() == SHAPE_TYPE_STATIC_MESH) {
|
||||||
if (glm::length(value) < MIN_LINEAR_SPEED) {
|
if (velocity != Vectors::ZERO) {
|
||||||
velocity = ENTITY_ITEM_ZERO_VEC3;
|
setLocalVelocity(Vectors::ZERO);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
velocity = value;
|
const float MIN_LINEAR_SPEED = 0.001f;
|
||||||
|
if (glm::length(value) < MIN_LINEAR_SPEED) {
|
||||||
|
velocity = ENTITY_ITEM_ZERO_VEC3;
|
||||||
|
} else {
|
||||||
|
velocity = value;
|
||||||
|
}
|
||||||
|
setLocalVelocity(velocity);
|
||||||
|
_dirtyFlags |= Simulation::DIRTY_LINEAR_VELOCITY;
|
||||||
}
|
}
|
||||||
setLocalVelocity(velocity);
|
|
||||||
_dirtyFlags |= Simulation::DIRTY_LINEAR_VELOCITY;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1630,22 +1636,30 @@ void EntityItem::updateDamping(float value) {
|
||||||
|
|
||||||
void EntityItem::updateGravity(const glm::vec3& value) {
|
void EntityItem::updateGravity(const glm::vec3& value) {
|
||||||
if (_gravity != value) {
|
if (_gravity != value) {
|
||||||
_gravity = value;
|
if (getShapeType() == SHAPE_TYPE_STATIC_MESH) {
|
||||||
_dirtyFlags |= Simulation::DIRTY_LINEAR_VELOCITY;
|
_gravity = Vectors::ZERO;
|
||||||
|
} else {
|
||||||
|
_gravity = value;
|
||||||
|
_dirtyFlags |= Simulation::DIRTY_LINEAR_VELOCITY;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void EntityItem::updateAngularVelocity(const glm::vec3& value) {
|
void EntityItem::updateAngularVelocity(const glm::vec3& value) {
|
||||||
glm::vec3 angularVelocity = getLocalAngularVelocity();
|
glm::vec3 angularVelocity = getLocalAngularVelocity();
|
||||||
if (angularVelocity != value) {
|
if (angularVelocity != value) {
|
||||||
const float MIN_ANGULAR_SPEED = 0.0002f;
|
if (getShapeType() == SHAPE_TYPE_STATIC_MESH) {
|
||||||
if (glm::length(value) < MIN_ANGULAR_SPEED) {
|
setLocalAngularVelocity(Vectors::ZERO);
|
||||||
angularVelocity = ENTITY_ITEM_ZERO_VEC3;
|
|
||||||
} else {
|
} else {
|
||||||
angularVelocity = value;
|
const float MIN_ANGULAR_SPEED = 0.0002f;
|
||||||
|
if (glm::length(value) < MIN_ANGULAR_SPEED) {
|
||||||
|
angularVelocity = ENTITY_ITEM_ZERO_VEC3;
|
||||||
|
} else {
|
||||||
|
angularVelocity = value;
|
||||||
|
}
|
||||||
|
setLocalAngularVelocity(angularVelocity);
|
||||||
|
_dirtyFlags |= Simulation::DIRTY_ANGULAR_VELOCITY;
|
||||||
}
|
}
|
||||||
setLocalAngularVelocity(angularVelocity);
|
|
||||||
_dirtyFlags |= Simulation::DIRTY_ANGULAR_VELOCITY;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1680,8 +1694,12 @@ void EntityItem::updateCollisionMask(uint8_t value) {
|
||||||
|
|
||||||
void EntityItem::updateDynamic(bool value) {
|
void EntityItem::updateDynamic(bool value) {
|
||||||
if (_dynamic != value) {
|
if (_dynamic != value) {
|
||||||
_dynamic = value;
|
if (getShapeType() == SHAPE_TYPE_STATIC_MESH) {
|
||||||
_dirtyFlags |= Simulation::DIRTY_MOTION_TYPE;
|
_dynamic = false;
|
||||||
|
} else {
|
||||||
|
_dynamic = value;
|
||||||
|
_dirtyFlags |= Simulation::DIRTY_MOTION_TYPE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue