mirror of
https://github.com/overte-org/overte.git
synced 2025-07-16 00:56:48 +02:00
Fix entity density not setting and not updating for motion states
This commit is contained in:
parent
1fd3f80210
commit
9a00edd371
5 changed files with 17 additions and 8 deletions
|
@ -27,6 +27,10 @@ void AvatarMotionState::handleEasyChanges(uint32_t& flags) {
|
||||||
if (flags & Simulation::DIRTY_PHYSICS_ACTIVATION && !_body->isActive()) {
|
if (flags & Simulation::DIRTY_PHYSICS_ACTIVATION && !_body->isActive()) {
|
||||||
_body->activate();
|
_body->activate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (flags & Simulation::DIRTY_MASS) {
|
||||||
|
updateBodyMassProperties();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
AvatarMotionState::~AvatarMotionState() {
|
AvatarMotionState::~AvatarMotionState() {
|
||||||
|
|
|
@ -31,6 +31,10 @@ void DetailedMotionState::handleEasyChanges(uint32_t& flags) {
|
||||||
if (flags & Simulation::DIRTY_PHYSICS_ACTIVATION && !_body->isActive()) {
|
if (flags & Simulation::DIRTY_PHYSICS_ACTIVATION && !_body->isActive()) {
|
||||||
_body->activate();
|
_body->activate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (flags & Simulation::DIRTY_MASS) {
|
||||||
|
updateBodyMassProperties();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DetailedMotionState::~DetailedMotionState() {
|
DetailedMotionState::~DetailedMotionState() {
|
||||||
|
|
|
@ -57,9 +57,9 @@ const glm::vec3 ENTITY_ITEM_DEFAULT_DIMENSIONS = glm::vec3(ENTITY_ITEM_DEFAULT_W
|
||||||
const float ENTITY_ITEM_DEFAULT_VOLUME = ENTITY_ITEM_DEFAULT_WIDTH * ENTITY_ITEM_DEFAULT_WIDTH * ENTITY_ITEM_DEFAULT_WIDTH;
|
const float ENTITY_ITEM_DEFAULT_VOLUME = ENTITY_ITEM_DEFAULT_WIDTH * ENTITY_ITEM_DEFAULT_WIDTH * ENTITY_ITEM_DEFAULT_WIDTH;
|
||||||
const float ENTITY_ITEM_MIN_VOLUME = ENTITY_ITEM_MIN_DIMENSION * ENTITY_ITEM_MIN_DIMENSION * ENTITY_ITEM_MIN_DIMENSION;
|
const float ENTITY_ITEM_MIN_VOLUME = ENTITY_ITEM_MIN_DIMENSION * ENTITY_ITEM_MIN_DIMENSION * ENTITY_ITEM_MIN_DIMENSION;
|
||||||
|
|
||||||
const float ENTITY_ITEM_MAX_DENSITY = 10000.0f; // kg/m^3 density of silver
|
const float ENTITY_ITEM_MAX_DENSITY = 100000.0f; // kg/m^3 more than 5 times density of tungsten.
|
||||||
const float ENTITY_ITEM_MIN_DENSITY = 100.0f; // kg/m^3 density of balsa wood
|
const float ENTITY_ITEM_MIN_DENSITY = 0.1f; // kg/m^3 ten times less than air density.
|
||||||
const float ENTITY_ITEM_DEFAULT_DENSITY = 1000.0f; // density of water
|
const float ENTITY_ITEM_DEFAULT_DENSITY = 1000.0f; // density of water.
|
||||||
const float ENTITY_ITEM_DEFAULT_MASS = ENTITY_ITEM_DEFAULT_DENSITY * ENTITY_ITEM_DEFAULT_VOLUME;
|
const float ENTITY_ITEM_DEFAULT_MASS = ENTITY_ITEM_DEFAULT_DENSITY * ENTITY_ITEM_DEFAULT_VOLUME;
|
||||||
|
|
||||||
const glm::vec3 ENTITY_ITEM_DEFAULT_VELOCITY = ENTITY_ITEM_ZERO_VEC3;
|
const glm::vec3 ENTITY_ITEM_DEFAULT_VELOCITY = ENTITY_ITEM_ZERO_VEC3;
|
||||||
|
|
|
@ -57,10 +57,10 @@ EntityMotionState::EntityMotionState(btCollisionShape* shape, EntityItemPointer
|
||||||
|
|
||||||
_type = MOTIONSTATE_TYPE_ENTITY;
|
_type = MOTIONSTATE_TYPE_ENTITY;
|
||||||
assert(_entity);
|
assert(_entity);
|
||||||
setMass(_entity->computeMass());
|
|
||||||
// we need the side-effects of EntityMotionState::setShape() so we call it explicitly here
|
// we need the side-effects of EntityMotionState::setShape() so we call it explicitly here
|
||||||
// rather than pass the legit shape pointer to the ObjectMotionState ctor above.
|
// rather than pass the legit shape pointer to the ObjectMotionState ctor above.
|
||||||
setShape(shape);
|
setShape(shape);
|
||||||
|
setMass(_entity->computeMass());
|
||||||
|
|
||||||
if (_entity->isAvatarEntity() && !_entity->isMyAvatarEntity()) {
|
if (_entity->isAvatarEntity() && !_entity->isMyAvatarEntity()) {
|
||||||
// avatar entities are always thus, so we cache this fact in _ownershipState
|
// avatar entities are always thus, so we cache this fact in _ownershipState
|
||||||
|
@ -178,6 +178,11 @@ void EntityMotionState::handleEasyChanges(uint32_t& flags) {
|
||||||
_body->activate();
|
_body->activate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (flags & Simulation::DIRTY_MASS) {
|
||||||
|
setMass(_entity->computeMass());
|
||||||
|
updateBodyMassProperties();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -284,10 +284,6 @@ void ObjectMotionState::handleEasyChanges(uint32_t& flags) {
|
||||||
if (flags & Simulation::DIRTY_MATERIAL) {
|
if (flags & Simulation::DIRTY_MATERIAL) {
|
||||||
updateBodyMaterialProperties();
|
updateBodyMaterialProperties();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flags & Simulation::DIRTY_MASS) {
|
|
||||||
updateBodyMassProperties();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ObjectMotionState::updateBodyMaterialProperties() {
|
void ObjectMotionState::updateBodyMaterialProperties() {
|
||||||
|
|
Loading…
Reference in a new issue