mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 20:23:06 +02:00
Make the changes - big thanks to Andrew!
This commit is contained in:
parent
54bca1e53d
commit
64191ee20a
4 changed files with 19 additions and 8 deletions
|
@ -1091,15 +1091,18 @@ void EntityTreeRenderer::entityCollisionWithEntity(const EntityItemID& idA, cons
|
||||||
|
|
||||||
// trigger scripted collision sounds and events for locally owned objects
|
// trigger scripted collision sounds and events for locally owned objects
|
||||||
EntityItemPointer entityA = entityTree->findEntityByEntityItemID(idA);
|
EntityItemPointer entityA = entityTree->findEntityByEntityItemID(idA);
|
||||||
if ((bool)entityA && myNodeID == entityA->getSimulatorID()) {
|
EntityItemPointer entityB = entityTree->findEntityByEntityItemID(idB);
|
||||||
|
QUuid entityASimulatorID = entityA->getSimulatorID();
|
||||||
|
QUuid entityBSimulatorID = entityB->getSimulatorID();
|
||||||
|
if ((bool)entityA && (myNodeID == entityASimulatorID || ((bool)entityB && myNodeID == entityBSimulatorID && entityASimulatorID.isNull()))) {
|
||||||
playEntityCollisionSound(entityA, collision);
|
playEntityCollisionSound(entityA, collision);
|
||||||
emit collisionWithEntity(idA, idB, collision);
|
emit collisionWithEntity(idA, idB, collision);
|
||||||
if (_entitiesScriptEngine) {
|
if (_entitiesScriptEngine) {
|
||||||
_entitiesScriptEngine->callEntityScriptMethod(idA, "collisionWithEntity", idB, collision);
|
_entitiesScriptEngine->callEntityScriptMethod(idA, "collisionWithEntity", idB, collision);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
EntityItemPointer entityB = entityTree->findEntityByEntityItemID(idB);
|
|
||||||
if ((bool)entityB && myNodeID == entityB->getSimulatorID()) {
|
if ((bool)entityB && (myNodeID == entityBSimulatorID || ((bool)entityA && myNodeID == entityASimulatorID && entityBSimulatorID.isNull()))) {
|
||||||
playEntityCollisionSound(entityB, collision);
|
playEntityCollisionSound(entityB, collision);
|
||||||
// since we're swapping A and B we need to send the inverted collision
|
// since we're swapping A and B we need to send the inverted collision
|
||||||
Collision invertedCollision(collision);
|
Collision invertedCollision(collision);
|
||||||
|
|
|
@ -1824,10 +1824,15 @@ bool EntityItemProperties::hasTerseUpdateChanges() const {
|
||||||
return _positionChanged || _velocityChanged || _rotationChanged || _angularVelocityChanged || _accelerationChanged;
|
return _positionChanged || _velocityChanged || _rotationChanged || _angularVelocityChanged || _accelerationChanged;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool EntityItemProperties::hasDynamicPhysicsChanges() const {
|
||||||
|
return _dynamicChanged || _velocityChanged || _angularVelocityChanged || _accelerationChanged;
|
||||||
|
}
|
||||||
|
|
||||||
bool EntityItemProperties::hasMiscPhysicsChanges() const {
|
bool EntityItemProperties::hasMiscPhysicsChanges() const {
|
||||||
return _gravityChanged || _dimensionsChanged || _densityChanged || _frictionChanged
|
return _gravityChanged || _dimensionsChanged || _densityChanged || _frictionChanged
|
||||||
|| _restitutionChanged || _dampingChanged || _angularDampingChanged || _registrationPointChanged ||
|
|| _restitutionChanged || _dampingChanged || _angularDampingChanged || _registrationPointChanged ||
|
||||||
_compoundShapeURLChanged || _dynamicChanged || _collisionlessChanged || _collisionMaskChanged;
|
_compoundShapeURLChanged || _collisionlessChanged || _collisionMaskChanged ||
|
||||||
|
_rotationChanged || _positionChanged;
|
||||||
}
|
}
|
||||||
|
|
||||||
void EntityItemProperties::clearSimulationOwner() {
|
void EntityItemProperties::clearSimulationOwner() {
|
||||||
|
|
|
@ -274,6 +274,7 @@ public:
|
||||||
void setCreated(QDateTime& v);
|
void setCreated(QDateTime& v);
|
||||||
|
|
||||||
bool hasTerseUpdateChanges() const;
|
bool hasTerseUpdateChanges() const;
|
||||||
|
bool hasDynamicPhysicsChanges() const;
|
||||||
bool hasMiscPhysicsChanges() const;
|
bool hasMiscPhysicsChanges() const;
|
||||||
|
|
||||||
void clearSimulationOwner();
|
void clearSimulationOwner();
|
||||||
|
|
|
@ -414,15 +414,17 @@ QUuid EntityScriptingInterface::editEntity(QUuid id, const EntityItemProperties&
|
||||||
entityFound = true;
|
entityFound = true;
|
||||||
// make sure the properties has a type, so that the encode can know which properties to include
|
// make sure the properties has a type, so that the encode can know which properties to include
|
||||||
properties.setType(entity->getType());
|
properties.setType(entity->getType());
|
||||||
bool hasTerseUpdateChanges = properties.hasTerseUpdateChanges();
|
bool hasMiscPhysicsChanges = properties.hasMiscPhysicsChanges();
|
||||||
bool hasPhysicsChanges = properties.hasMiscPhysicsChanges() || hasTerseUpdateChanges;
|
bool hasDynamicsChanges = properties.hasDynamicPhysicsChanges();
|
||||||
if (_bidOnSimulationOwnership && hasPhysicsChanges) {
|
// _bidOnSimulationOwnership is set per-instance of the scripting interface.
|
||||||
|
// It essentially corresponds to "Am I an AC or an Interface client?" - ACs will never bid.
|
||||||
|
if ((_bidOnSimulationOwnership && ((hasMiscPhysicsChanges && entity->isMoving()) || hasDynamicsChanges))) {
|
||||||
auto nodeList = DependencyManager::get<NodeList>();
|
auto nodeList = DependencyManager::get<NodeList>();
|
||||||
const QUuid myNodeID = nodeList->getSessionUUID();
|
const QUuid myNodeID = nodeList->getSessionUUID();
|
||||||
|
|
||||||
if (entity->getSimulatorID() == myNodeID) {
|
if (entity->getSimulatorID() == myNodeID) {
|
||||||
// we think we already own the simulation, so make sure to send ALL TerseUpdate properties
|
// we think we already own the simulation, so make sure to send ALL TerseUpdate properties
|
||||||
if (hasTerseUpdateChanges) {
|
if (properties.hasTerseUpdateChanges()) {
|
||||||
entity->getAllTerseUpdateProperties(properties);
|
entity->getAllTerseUpdateProperties(properties);
|
||||||
}
|
}
|
||||||
// TODO: if we knew that ONLY TerseUpdate properties have changed in properties AND the object
|
// TODO: if we knew that ONLY TerseUpdate properties have changed in properties AND the object
|
||||||
|
|
Loading…
Reference in a new issue