mirror of
https://github.com/lubosz/overte.git
synced 2025-04-10 04:52:17 +02:00
adjust simulation bid priority by props changed
This commit is contained in:
parent
9bfa4a5267
commit
6558d539e4
3 changed files with 18 additions and 3 deletions
|
@ -3326,6 +3326,20 @@ void EntityItemProperties::setSimulationOwner(const QByteArray& data) {
|
|||
}
|
||||
}
|
||||
|
||||
uint8_t EntityItemProperties::computeSimulationBidPriority() const {
|
||||
uint8_t priority = 0;
|
||||
if (_parentIDChanged || _parentJointIndexChanged) {
|
||||
// we need higher simulation ownership priority to chang parenting info
|
||||
priority = SCRIPT_GRAB_SIMULATION_PRIORITY;
|
||||
} else if ( _positionChanged || _localPositionChanged
|
||||
|| _rotationChanged || _localRotationChanged
|
||||
|| _velocityChanged || _localVelocityChanged
|
||||
|| _angularVelocityChanged || _localAngularVelocityChanged) {
|
||||
priority = SCRIPT_POKE_SIMULATION_PRIORITY;
|
||||
}
|
||||
return priority;
|
||||
}
|
||||
|
||||
QList<QString> EntityItemProperties::listChangedProperties() {
|
||||
QList<QString> out;
|
||||
if (containsPositionChange()) {
|
||||
|
|
|
@ -360,6 +360,7 @@ public:
|
|||
void setSimulationOwner(const QUuid& id, uint8_t priority);
|
||||
void setSimulationOwner(const QByteArray& data);
|
||||
void setSimulationPriority(uint8_t priority) { _simulationOwner.setPriority(priority); }
|
||||
uint8_t computeSimulationBidPriority() const;
|
||||
|
||||
void setActionDataDirty() { _actionDataChanged = true; }
|
||||
|
||||
|
|
|
@ -562,14 +562,14 @@ QUuid EntityScriptingInterface::editEntity(QUuid id, const EntityItemProperties&
|
|||
if (entity) {
|
||||
if (properties.hasSimulationRestrictedChanges()) {
|
||||
if (_bidOnSimulationOwnership) {
|
||||
// flag for simulation ownership, or upgrade existing ownership priority
|
||||
// (actual bids for simulation ownership are sent by the PhysicalEntitySimulation)
|
||||
entity->upgradeScriptSimulationPriority(properties.computeSimulationBidPriority());
|
||||
if (simulationOwner.getID() == sessionID) {
|
||||
// we own the simulation --> copy ALL restricted properties
|
||||
properties.copySimulationRestrictedProperties(entity);
|
||||
} else {
|
||||
// we don't own the simulation but think we would like to
|
||||
// --> flag the object for simulation ownership at at least POKE
|
||||
// (the bid for simulation ownership (if any) will be sent by the physics simulation)
|
||||
entity->upgradeScriptSimulationPriority(SCRIPT_POKE_SIMULATION_PRIORITY);
|
||||
|
||||
uint8_t desiredPriority = entity->getScriptSimulationPriority();
|
||||
if (desiredPriority < simulationOwner.getPriority()) {
|
||||
|
|
Loading…
Reference in a new issue