mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 09:57:26 +02:00
Merge pull request #7192 from zzmp/fix/zone-edit-update
Update Scene on ZoneEntity update
This commit is contained in:
commit
09e4c54831
4 changed files with 38 additions and 12 deletions
|
@ -134,14 +134,14 @@ void EntityTreeRenderer::update() {
|
||||||
EntityTreePointer tree = std::static_pointer_cast<EntityTree>(_tree);
|
EntityTreePointer tree = std::static_pointer_cast<EntityTree>(_tree);
|
||||||
tree->update();
|
tree->update();
|
||||||
|
|
||||||
// check to see if the avatar has moved and if we need to handle enter/leave entity logic
|
// Handle enter/leave entity logic
|
||||||
checkEnterLeaveEntities();
|
bool updated = checkEnterLeaveEntities();
|
||||||
|
|
||||||
// even if we haven't changed positions, if we previously attempted to set the skybox, but
|
// If we haven't already updated and previously attempted to load a texture,
|
||||||
// have a pending download of the skybox texture, then we should attempt to reapply to
|
// check if the texture loaded and apply it
|
||||||
// get the correct texture.
|
if (!updated && (
|
||||||
if ((_pendingSkyboxTexture && _skyboxTexture && _skyboxTexture->isLoaded()) ||
|
(_pendingSkyboxTexture && _skyboxTexture && _skyboxTexture->isLoaded()) ||
|
||||||
(_pendingAmbientTexture && _ambientTexture && _ambientTexture->isLoaded())) {
|
(_pendingAmbientTexture && _ambientTexture && _ambientTexture->isLoaded()))) {
|
||||||
applyZonePropertiesToScene(_bestZone);
|
applyZonePropertiesToScene(_bestZone);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -157,7 +157,7 @@ void EntityTreeRenderer::update() {
|
||||||
deleteReleasedModels();
|
deleteReleasedModels();
|
||||||
}
|
}
|
||||||
|
|
||||||
void EntityTreeRenderer::checkEnterLeaveEntities() {
|
bool EntityTreeRenderer::checkEnterLeaveEntities() {
|
||||||
if (_tree && !_shuttingDown) {
|
if (_tree && !_shuttingDown) {
|
||||||
glm::vec3 avatarPosition = _viewState->getAvatarPosition();
|
glm::vec3 avatarPosition = _viewState->getAvatarPosition();
|
||||||
|
|
||||||
|
@ -172,7 +172,7 @@ void EntityTreeRenderer::checkEnterLeaveEntities() {
|
||||||
std::static_pointer_cast<EntityTree>(_tree)->findEntities(avatarPosition, radius, foundEntities);
|
std::static_pointer_cast<EntityTree>(_tree)->findEntities(avatarPosition, radius, foundEntities);
|
||||||
|
|
||||||
// Whenever you're in an intersection between zones, we will always choose the smallest zone.
|
// Whenever you're in an intersection between zones, we will always choose the smallest zone.
|
||||||
_bestZone = NULL; // NOTE: Is this what we want?
|
_bestZone = nullptr; // NOTE: Is this what we want?
|
||||||
_bestZoneVolume = std::numeric_limits<float>::max();
|
_bestZoneVolume = std::numeric_limits<float>::max();
|
||||||
|
|
||||||
// create a list of entities that actually contain the avatar's position
|
// create a list of entities that actually contain the avatar's position
|
||||||
|
@ -205,7 +205,6 @@ void EntityTreeRenderer::checkEnterLeaveEntities() {
|
||||||
}
|
}
|
||||||
|
|
||||||
applyZonePropertiesToScene(_bestZone);
|
applyZonePropertiesToScene(_bestZone);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Note: at this point we don't need to worry about the tree being locked, because we only deal with
|
// Note: at this point we don't need to worry about the tree being locked, because we only deal with
|
||||||
|
@ -229,8 +228,11 @@ void EntityTreeRenderer::checkEnterLeaveEntities() {
|
||||||
}
|
}
|
||||||
_currentEntitiesInside = entitiesContainingAvatar;
|
_currentEntitiesInside = entitiesContainingAvatar;
|
||||||
_lastAvatarPosition = avatarPosition;
|
_lastAvatarPosition = avatarPosition;
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void EntityTreeRenderer::leaveAllEntities() {
|
void EntityTreeRenderer::leaveAllEntities() {
|
||||||
|
@ -851,3 +853,19 @@ void EntityTreeRenderer::updateEntityRenderStatus(bool shouldRenderEntities) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EntityTreeRenderer::updateZone(const EntityItemID& id) {
|
||||||
|
if (!_bestZone) {
|
||||||
|
// Get in the zone!
|
||||||
|
auto zone = getTree()->findEntityByEntityItemID(id);
|
||||||
|
if (zone && zone->contains(_lastAvatarPosition)) {
|
||||||
|
_currentEntitiesInside << id;
|
||||||
|
emit enterEntity(id);
|
||||||
|
_entitiesScriptEngine->callEntityScriptMethod(id, "enterEntity");
|
||||||
|
_bestZone = std::dynamic_pointer_cast<ZoneEntityItem>(zone);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (_bestZone && _bestZone->getID() == id) {
|
||||||
|
applyZonePropertiesToScene(_bestZone);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -109,6 +109,7 @@ public slots:
|
||||||
void entitySciptChanging(const EntityItemID& entityID, const bool reload);
|
void entitySciptChanging(const EntityItemID& entityID, const bool reload);
|
||||||
void entityCollisionWithEntity(const EntityItemID& idA, const EntityItemID& idB, const Collision& collision);
|
void entityCollisionWithEntity(const EntityItemID& idA, const EntityItemID& idB, const Collision& collision);
|
||||||
void updateEntityRenderStatus(bool shouldRenderEntities);
|
void updateEntityRenderStatus(bool shouldRenderEntities);
|
||||||
|
void updateZone(const EntityItemID& id);
|
||||||
|
|
||||||
// optional slots that can be wired to menu items
|
// optional slots that can be wired to menu items
|
||||||
void setDisplayModelBounds(bool value) { _displayModelBounds = value; }
|
void setDisplayModelBounds(bool value) { _displayModelBounds = value; }
|
||||||
|
@ -136,11 +137,11 @@ private:
|
||||||
EntityItemID _currentClickingOnEntityID;
|
EntityItemID _currentClickingOnEntityID;
|
||||||
|
|
||||||
QScriptValueList createEntityArgs(const EntityItemID& entityID);
|
QScriptValueList createEntityArgs(const EntityItemID& entityID);
|
||||||
void checkEnterLeaveEntities();
|
bool checkEnterLeaveEntities();
|
||||||
void leaveAllEntities();
|
void leaveAllEntities();
|
||||||
void forceRecheckEntities();
|
void forceRecheckEntities();
|
||||||
|
|
||||||
glm::vec3 _lastAvatarPosition;
|
glm::vec3 _lastAvatarPosition { 0.0f };
|
||||||
QVector<EntityItemID> _currentEntitiesInside;
|
QVector<EntityItemID> _currentEntitiesInside;
|
||||||
|
|
||||||
bool _pendingSkyboxTexture { false };
|
bool _pendingSkyboxTexture { false };
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
#include <GeometryCache.h>
|
#include <GeometryCache.h>
|
||||||
#include <PerfStat.h>
|
#include <PerfStat.h>
|
||||||
|
|
||||||
|
#include "EntityTreeRenderer.h"
|
||||||
#include "RenderableEntityItem.h"
|
#include "RenderableEntityItem.h"
|
||||||
|
|
||||||
// Sphere entities should fit inside a cube entity of the same size, so a sphere that has dimensions 1x1x1
|
// Sphere entities should fit inside a cube entity of the same size, so a sphere that has dimensions 1x1x1
|
||||||
|
@ -62,6 +63,10 @@ bool RenderableZoneEntityItem::setProperties(const EntityItemProperties& propert
|
||||||
return somethingChanged;
|
return somethingChanged;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RenderableZoneEntityItem::somethingChangedNotification() {
|
||||||
|
DependencyManager::get<EntityTreeRenderer>()->updateZone(_id);
|
||||||
|
}
|
||||||
|
|
||||||
int RenderableZoneEntityItem::readEntitySubclassDataFromBuffer(const unsigned char* data, int bytesLeftToRead,
|
int RenderableZoneEntityItem::readEntitySubclassDataFromBuffer(const unsigned char* data, int bytesLeftToRead,
|
||||||
ReadBitstreamToTreeParams& args,
|
ReadBitstreamToTreeParams& args,
|
||||||
EntityPropertyFlags& propertyFlags, bool overwriteLocalData,
|
EntityPropertyFlags& propertyFlags, bool overwriteLocalData,
|
||||||
|
|
|
@ -28,6 +28,8 @@ public:
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
virtual bool setProperties(const EntityItemProperties& properties);
|
virtual bool setProperties(const EntityItemProperties& properties);
|
||||||
|
virtual void somethingChangedNotification() override;
|
||||||
|
|
||||||
virtual int readEntitySubclassDataFromBuffer(const unsigned char* data, int bytesLeftToRead,
|
virtual int readEntitySubclassDataFromBuffer(const unsigned char* data, int bytesLeftToRead,
|
||||||
ReadBitstreamToTreeParams& args,
|
ReadBitstreamToTreeParams& args,
|
||||||
EntityPropertyFlags& propertyFlags, bool overwriteLocalData,
|
EntityPropertyFlags& propertyFlags, bool overwriteLocalData,
|
||||||
|
|
Loading…
Reference in a new issue