mirror of
https://github.com/JulianGro/overte.git
synced 2025-05-01 15:59:44 +02:00
Merge pull request #9609 from sethalves/tablet-ui-fix-equipping
don't send AVATAR_SELF_ID over wire
This commit is contained in:
commit
194fd925cf
4 changed files with 58 additions and 30 deletions
|
@ -100,7 +100,18 @@ void EntityEditPacketSender::queueEditEntityMessage(PacketType type,
|
||||||
|
|
||||||
QByteArray bufferOut(NLPacket::maxPayloadSize(type), 0);
|
QByteArray bufferOut(NLPacket::maxPayloadSize(type), 0);
|
||||||
|
|
||||||
if (EntityItemProperties::encodeEntityEditPacket(type, entityItemID, properties, bufferOut)) {
|
bool success;
|
||||||
|
if (properties.parentIDChanged() && properties.getParentID() == AVATAR_SELF_ID) {
|
||||||
|
EntityItemProperties propertiesCopy = properties;
|
||||||
|
auto nodeList = DependencyManager::get<NodeList>();
|
||||||
|
const QUuid myNodeID = nodeList->getSessionUUID();
|
||||||
|
propertiesCopy.setParentID(myNodeID);
|
||||||
|
success = EntityItemProperties::encodeEntityEditPacket(type, entityItemID, propertiesCopy, bufferOut);
|
||||||
|
} else {
|
||||||
|
success = EntityItemProperties::encodeEntityEditPacket(type, entityItemID, properties, bufferOut);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (success) {
|
||||||
#ifdef WANT_DEBUG
|
#ifdef WANT_DEBUG
|
||||||
qCDebug(entities) << "calling queueOctreeEditMessage()...";
|
qCDebug(entities) << "calling queueOctreeEditMessage()...";
|
||||||
qCDebug(entities) << " id:" << entityItemID;
|
qCDebug(entities) << " id:" << entityItemID;
|
||||||
|
|
|
@ -828,7 +828,7 @@ int EntityItem::readEntityDataFromBuffer(const unsigned char* data, int bytesLef
|
||||||
{ // parentID and parentJointIndex are also protected by simulation ownership
|
{ // parentID and parentJointIndex are also protected by simulation ownership
|
||||||
bool oldOverwrite = overwriteLocalData;
|
bool oldOverwrite = overwriteLocalData;
|
||||||
overwriteLocalData = overwriteLocalData && !weOwnSimulation;
|
overwriteLocalData = overwriteLocalData && !weOwnSimulation;
|
||||||
READ_ENTITY_PROPERTY(PROP_PARENT_ID, QUuid, setParentID);
|
READ_ENTITY_PROPERTY(PROP_PARENT_ID, QUuid, updateParentID);
|
||||||
READ_ENTITY_PROPERTY(PROP_PARENT_JOINT_INDEX, quint16, setParentJointIndex);
|
READ_ENTITY_PROPERTY(PROP_PARENT_JOINT_INDEX, quint16, setParentJointIndex);
|
||||||
overwriteLocalData = oldOverwrite;
|
overwriteLocalData = oldOverwrite;
|
||||||
}
|
}
|
||||||
|
@ -1823,28 +1823,6 @@ void EntityItem::computeCollisionGroupAndFinalMask(int16_t& group, int16_t& mask
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t userMask = getCollisionMask();
|
uint8_t userMask = getCollisionMask();
|
||||||
if (userMask & USER_COLLISION_GROUP_MY_AVATAR) {
|
|
||||||
// if this entity is a descendant of MyAvatar, don't collide with MyAvatar. This avoids the
|
|
||||||
// "bootstrapping" problem where you can shoot yourself across the room by grabbing something
|
|
||||||
// and holding it against your own avatar.
|
|
||||||
QUuid ancestorID = findAncestorOfType(NestableType::Avatar);
|
|
||||||
if (!ancestorID.isNull() && ancestorID == Physics::getSessionUUID()) {
|
|
||||||
userMask &= ~USER_COLLISION_GROUP_MY_AVATAR;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (userMask & USER_COLLISION_GROUP_MY_AVATAR) {
|
|
||||||
// also, don't bootstrap our own avatar with a hold action
|
|
||||||
QList<EntityActionPointer> holdActions = getActionsOfType(ACTION_TYPE_HOLD);
|
|
||||||
QList<EntityActionPointer>::const_iterator i = holdActions.begin();
|
|
||||||
while (i != holdActions.end()) {
|
|
||||||
EntityActionPointer action = *i;
|
|
||||||
if (action->isMine()) {
|
|
||||||
userMask &= ~USER_COLLISION_GROUP_MY_AVATAR;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((bool)(userMask & USER_COLLISION_GROUP_MY_AVATAR) !=
|
if ((bool)(userMask & USER_COLLISION_GROUP_MY_AVATAR) !=
|
||||||
(bool)(userMask & USER_COLLISION_GROUP_OTHER_AVATAR)) {
|
(bool)(userMask & USER_COLLISION_GROUP_OTHER_AVATAR)) {
|
||||||
|
@ -1854,6 +1832,33 @@ void EntityItem::computeCollisionGroupAndFinalMask(int16_t& group, int16_t& mask
|
||||||
userMask ^= USER_COLLISION_MASK_AVATARS | ~userMask;
|
userMask ^= USER_COLLISION_MASK_AVATARS | ~userMask;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (userMask & USER_COLLISION_GROUP_MY_AVATAR) {
|
||||||
|
bool iAmHoldingThis = false;
|
||||||
|
// if this entity is a descendant of MyAvatar, don't collide with MyAvatar. This avoids the
|
||||||
|
// "bootstrapping" problem where you can shoot yourself across the room by grabbing something
|
||||||
|
// and holding it against your own avatar.
|
||||||
|
QUuid ancestorID = findAncestorOfType(NestableType::Avatar);
|
||||||
|
if (!ancestorID.isNull() &&
|
||||||
|
(ancestorID == Physics::getSessionUUID() || ancestorID == AVATAR_SELF_ID)) {
|
||||||
|
iAmHoldingThis = true;
|
||||||
|
}
|
||||||
|
// also, don't bootstrap our own avatar with a hold action
|
||||||
|
QList<EntityActionPointer> holdActions = getActionsOfType(ACTION_TYPE_HOLD);
|
||||||
|
QList<EntityActionPointer>::const_iterator i = holdActions.begin();
|
||||||
|
while (i != holdActions.end()) {
|
||||||
|
EntityActionPointer action = *i;
|
||||||
|
if (action->isMine()) {
|
||||||
|
iAmHoldingThis = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (iAmHoldingThis) {
|
||||||
|
userMask &= ~USER_COLLISION_GROUP_MY_AVATAR;
|
||||||
|
}
|
||||||
|
}
|
||||||
mask = Physics::getDefaultCollisionMask(group) & (int16_t)(userMask);
|
mask = Physics::getDefaultCollisionMask(group) & (int16_t)(userMask);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -199,15 +199,12 @@ void EntityMotionState::getWorldTransform(btTransform& worldTrans) const {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
assert(entityTreeIsLocked());
|
assert(entityTreeIsLocked());
|
||||||
if (_motionType == MOTION_TYPE_KINEMATIC) {
|
if (_motionType == MOTION_TYPE_KINEMATIC && !_entity->hasAncestorOfType(NestableType::Avatar)) {
|
||||||
BT_PROFILE("kinematicIntegration");
|
BT_PROFILE("kinematicIntegration");
|
||||||
// This is physical kinematic motion which steps strictly by the subframe count
|
// This is physical kinematic motion which steps strictly by the subframe count
|
||||||
// of the physics simulation and uses full gravity for acceleration.
|
// of the physics simulation and uses full gravity for acceleration.
|
||||||
if (_entity->hasAncestorOfType(NestableType::Avatar)) {
|
_entity->setAcceleration(_entity->getGravity());
|
||||||
_entity->setAcceleration(glm::vec3(0.0f));
|
|
||||||
} else {
|
|
||||||
_entity->setAcceleration(_entity->getGravity());
|
|
||||||
}
|
|
||||||
uint32_t thisStep = ObjectMotionState::getWorldSimulationStep();
|
uint32_t thisStep = ObjectMotionState::getWorldSimulationStep();
|
||||||
float dt = (thisStep - _lastKinematicStep) * PHYSICS_ENGINE_FIXED_SUBSTEP;
|
float dt = (thisStep - _lastKinematicStep) * PHYSICS_ENGINE_FIXED_SUBSTEP;
|
||||||
_entity->stepKinematicMotion(dt);
|
_entity->stepKinematicMotion(dt);
|
||||||
|
|
|
@ -1034,6 +1034,13 @@ AACube SpatiallyNestable::getQueryAACube() const {
|
||||||
|
|
||||||
bool SpatiallyNestable::hasAncestorOfType(NestableType nestableType) const {
|
bool SpatiallyNestable::hasAncestorOfType(NestableType nestableType) const {
|
||||||
bool success;
|
bool success;
|
||||||
|
if (nestableType == NestableType::Avatar) {
|
||||||
|
QUuid parentID = getParentID();
|
||||||
|
if (parentID == AVATAR_SELF_ID) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
SpatiallyNestablePointer parent = getParentPointer(success);
|
SpatiallyNestablePointer parent = getParentPointer(success);
|
||||||
if (!success || !parent) {
|
if (!success || !parent) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -1048,6 +1055,14 @@ bool SpatiallyNestable::hasAncestorOfType(NestableType nestableType) const {
|
||||||
|
|
||||||
const QUuid SpatiallyNestable::findAncestorOfType(NestableType nestableType) const {
|
const QUuid SpatiallyNestable::findAncestorOfType(NestableType nestableType) const {
|
||||||
bool success;
|
bool success;
|
||||||
|
|
||||||
|
if (nestableType == NestableType::Avatar) {
|
||||||
|
QUuid parentID = getParentID();
|
||||||
|
if (parentID == AVATAR_SELF_ID) {
|
||||||
|
return AVATAR_SELF_ID; // TODO -- can we put nodeID here?
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
SpatiallyNestablePointer parent = getParentPointer(success);
|
SpatiallyNestablePointer parent = getParentPointer(success);
|
||||||
if (!success || !parent) {
|
if (!success || !parent) {
|
||||||
return QUuid();
|
return QUuid();
|
||||||
|
|
Loading…
Reference in a new issue