mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-09 21:26:25 +02:00
hook up zone flyingAllowed flag to character controller
This commit is contained in:
parent
0fe4e42511
commit
ef85cc7803
4 changed files with 27 additions and 0 deletions
|
@ -426,7 +426,12 @@ void MyAvatar::simulate(float deltaTime) {
|
||||||
EntityTreeRenderer* entityTreeRenderer = qApp->getEntities();
|
EntityTreeRenderer* entityTreeRenderer = qApp->getEntities();
|
||||||
EntityTreePointer entityTree = entityTreeRenderer ? entityTreeRenderer->getTree() : nullptr;
|
EntityTreePointer entityTree = entityTreeRenderer ? entityTreeRenderer->getTree() : nullptr;
|
||||||
if (entityTree) {
|
if (entityTree) {
|
||||||
|
bool flyingAllowed = true;
|
||||||
entityTree->withWriteLock([&] {
|
entityTree->withWriteLock([&] {
|
||||||
|
std::shared_ptr<ZoneEntityItem> zone = entityTreeRenderer->myAvatarZone();
|
||||||
|
if (zone) {
|
||||||
|
flyingAllowed = zone->getFlyingAllowed();
|
||||||
|
}
|
||||||
auto now = usecTimestampNow();
|
auto now = usecTimestampNow();
|
||||||
EntityEditPacketSender* packetSender = qApp->getEntityEditPacketSender();
|
EntityEditPacketSender* packetSender = qApp->getEntityEditPacketSender();
|
||||||
MovingEntitiesOperator moveOperator(entityTree);
|
MovingEntitiesOperator moveOperator(entityTree);
|
||||||
|
@ -454,6 +459,7 @@ void MyAvatar::simulate(float deltaTime) {
|
||||||
entityTree->recurseTreeWithOperator(&moveOperator);
|
entityTree->recurseTreeWithOperator(&moveOperator);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
_characterController.setFlyingAllowed(flyingAllowed);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -88,6 +88,8 @@ public:
|
||||||
// For Scene.shouldRenderEntities
|
// For Scene.shouldRenderEntities
|
||||||
QList<EntityItemID>& getEntitiesLastInScene() { return _entityIDsLastInScene; }
|
QList<EntityItemID>& getEntitiesLastInScene() { return _entityIDsLastInScene; }
|
||||||
|
|
||||||
|
std::shared_ptr<ZoneEntityItem> myAvatarZone() { return _bestZone; }
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void mousePressOnEntity(const RayToEntityIntersectionResult& intersection, const QMouseEvent* event);
|
void mousePressOnEntity(const RayToEntityIntersectionResult& intersection, const QMouseEvent* event);
|
||||||
void mousePressOffEntity(const RayToEntityIntersectionResult& intersection, const QMouseEvent* event);
|
void mousePressOffEntity(const RayToEntityIntersectionResult& intersection, const QMouseEvent* event);
|
||||||
|
|
|
@ -294,6 +294,10 @@ void CharacterController::setState(State desiredState, const char* reason) {
|
||||||
#else
|
#else
|
||||||
void CharacterController::setState(State desiredState) {
|
void CharacterController::setState(State desiredState) {
|
||||||
#endif
|
#endif
|
||||||
|
if (!_flyingAllowed && desiredState == State::Hover) {
|
||||||
|
desiredState = State::InAir;
|
||||||
|
}
|
||||||
|
|
||||||
if (desiredState != _state) {
|
if (desiredState != _state) {
|
||||||
#ifdef DEBUG_STATE_CHANGE
|
#ifdef DEBUG_STATE_CHANGE
|
||||||
qCDebug(physics) << "CharacterController::setState" << stateToStr(desiredState) << "from" << stateToStr(_state) << "," << reason;
|
qCDebug(physics) << "CharacterController::setState" << stateToStr(desiredState) << "from" << stateToStr(_state) << "," << reason;
|
||||||
|
@ -544,3 +548,13 @@ bool CharacterController::getRigidBodyLocation(glm::vec3& avatarRigidBodyPositio
|
||||||
avatarRigidBodyRotation = bulletToGLM(worldTrans.getRotation());
|
avatarRigidBodyRotation = bulletToGLM(worldTrans.getRotation());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CharacterController::setFlyingAllowed(bool value) {
|
||||||
|
if (_flyingAllowed != value) {
|
||||||
|
_flyingAllowed = value;
|
||||||
|
|
||||||
|
if (!_flyingAllowed && _state == State::Hover) {
|
||||||
|
SET_STATE(State::InAir, "flying not allowed");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -98,6 +98,9 @@ public:
|
||||||
|
|
||||||
bool getRigidBodyLocation(glm::vec3& avatarRigidBodyPosition, glm::quat& avatarRigidBodyRotation);
|
bool getRigidBodyLocation(glm::vec3& avatarRigidBodyPosition, glm::quat& avatarRigidBodyRotation);
|
||||||
|
|
||||||
|
void setFlyingAllowed(bool value);
|
||||||
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
#ifdef DEBUG_STATE_CHANGE
|
#ifdef DEBUG_STATE_CHANGE
|
||||||
void setState(State state, const char* reason);
|
void setState(State state, const char* reason);
|
||||||
|
@ -147,6 +150,8 @@ protected:
|
||||||
btRigidBody* _rigidBody { nullptr };
|
btRigidBody* _rigidBody { nullptr };
|
||||||
uint32_t _pendingFlags { 0 };
|
uint32_t _pendingFlags { 0 };
|
||||||
uint32_t _previousFlags { 0 };
|
uint32_t _previousFlags { 0 };
|
||||||
|
|
||||||
|
bool _flyingAllowed { true };
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // hifi_CharacterControllerInterface_h
|
#endif // hifi_CharacterControllerInterface_h
|
||||||
|
|
Loading…
Reference in a new issue