mirror of
https://github.com/overte-org/overte.git
synced 2025-04-21 09:44:21 +02:00
Commuting the LIghtEntityItem changes correctly to the LightRenderItem
This commit is contained in:
parent
47aaed491d
commit
b563e280e4
6 changed files with 72 additions and 18 deletions
|
@ -45,7 +45,6 @@ public:
|
|||
static EntityItemPointer factory(const EntityItemID& entityID, const EntityItemProperties& properties);
|
||||
RenderableLightEntityItem(const EntityItemID& entityItemID);
|
||||
|
||||
|
||||
virtual bool supportsDetailedRayIntersection() const override { return true; }
|
||||
virtual bool findDetailedRayIntersection(const glm::vec3& origin, const glm::vec3& direction,
|
||||
bool& keepSearching, OctreeElementPointer& element, float& distance,
|
||||
|
@ -71,6 +70,13 @@ public:
|
|||
return true;
|
||||
}
|
||||
|
||||
virtual void somethingChangedNotification() override {
|
||||
if (_lightPropertiesChanged) {
|
||||
notifyChanged();
|
||||
}
|
||||
LightEntityItem::somethingChangedNotification();
|
||||
}
|
||||
|
||||
virtual void removeFromScene(EntityItemPointer self, std::shared_ptr<render::Scene> scene, render::PendingChanges& pendingChanges) override {
|
||||
pendingChanges.removeItem(_myItem);
|
||||
render::Item::clearID(_myItem);
|
||||
|
@ -113,7 +119,7 @@ private:
|
|||
bool _prevIsTransparent { isTransparent() };
|
||||
render::ItemID _myItem { render::Item::INVALID_ITEM_ID };
|
||||
|
||||
|
||||
// Dirty flag turn true when either setSubClassProperties or readEntitySubclassDataFromBuffer is changing a value
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -1313,6 +1313,10 @@ bool EntityItem::setProperties(const EntityItemProperties& properties) {
|
|||
somethingChanged = true;
|
||||
}
|
||||
|
||||
// Now check the sub classes
|
||||
somethingChanged |= setSubClassProperties(properties);
|
||||
|
||||
// Finally notify if change detected
|
||||
if (somethingChanged) {
|
||||
uint64_t now = usecTimestampNow();
|
||||
#ifdef WANT_DEBUG
|
||||
|
|
|
@ -90,7 +90,14 @@ public:
|
|||
virtual EntityItemProperties getProperties(EntityPropertyFlags desiredProperties = EntityPropertyFlags()) const;
|
||||
|
||||
/// returns true if something changed
|
||||
// THis function calls setSubClass properties and detects if any property changes value.
|
||||
// If something changed then the "somethingChangedNotification" calls happens
|
||||
virtual bool setProperties(const EntityItemProperties& properties);
|
||||
|
||||
// Set properties for sub class so they can add their own properties
|
||||
// it does nothing in the root eclass
|
||||
virtual bool setSubClassProperties(const EntityItemProperties& properties) { return false; }
|
||||
|
||||
// Update properties with empty parent id and globalized/absolute values (applying offset), and apply (non-empty) log template to args id, name-or-type, parent id.
|
||||
void globalizeProperties(EntityItemProperties& properties, const QString& messageTemplate = QString(), const glm::vec3& offset = glm::vec3(0.0f)) const;
|
||||
|
||||
|
|
|
@ -70,6 +70,7 @@ EntityItemProperties LightEntityItem::getProperties(EntityPropertyFlags desiredP
|
|||
|
||||
void LightEntityItem::setFalloffRadius(float value) {
|
||||
_falloffRadius = glm::max(value, 0.0f);
|
||||
_lightPropertiesChanged = true;
|
||||
}
|
||||
|
||||
void LightEntityItem::setIsSpotlight(bool value) {
|
||||
|
@ -85,6 +86,7 @@ void LightEntityItem::setIsSpotlight(bool value) {
|
|||
float maxDimension = glm::max(dimensions.x, dimensions.y, dimensions.z);
|
||||
setDimensions(glm::vec3(maxDimension, maxDimension, maxDimension));
|
||||
}
|
||||
_lightPropertiesChanged = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -98,10 +100,26 @@ void LightEntityItem::setCutoff(float value) {
|
|||
const float width = length * glm::sin(glm::radians(_cutoff));
|
||||
setDimensions(glm::vec3(width, width, length));
|
||||
}
|
||||
_lightPropertiesChanged = true;
|
||||
}
|
||||
|
||||
bool LightEntityItem::setProperties(const EntityItemProperties& properties) {
|
||||
bool somethingChanged = EntityItem::setProperties(properties); // set the properties in our base class
|
||||
if (somethingChanged) {
|
||||
bool wantDebug = false;
|
||||
if (wantDebug) {
|
||||
uint64_t now = usecTimestampNow();
|
||||
int elapsed = now - getLastEdited();
|
||||
qCDebug(entities) << "LightEntityItem::setProperties() AFTER update... edited AGO=" << elapsed <<
|
||||
"now=" << now << " getLastEdited()=" << getLastEdited();
|
||||
}
|
||||
setLastEdited(properties.getLastEdited());
|
||||
}
|
||||
return somethingChanged;
|
||||
}
|
||||
|
||||
bool LightEntityItem::setSubClassProperties(const EntityItemProperties& properties) {
|
||||
bool somethingChanged = EntityItem::setSubClassProperties(properties); // set the properties in our base class
|
||||
|
||||
SET_ENTITY_PROPERTY_FROM_PROPERTIES(isSpotlight, setIsSpotlight);
|
||||
SET_ENTITY_PROPERTY_FROM_PROPERTIES(color, setColor);
|
||||
|
@ -110,19 +128,10 @@ bool LightEntityItem::setProperties(const EntityItemProperties& properties) {
|
|||
SET_ENTITY_PROPERTY_FROM_PROPERTIES(cutoff, setCutoff);
|
||||
SET_ENTITY_PROPERTY_FROM_PROPERTIES(falloffRadius, setFalloffRadius);
|
||||
|
||||
if (somethingChanged) {
|
||||
bool wantDebug = false;
|
||||
if (wantDebug) {
|
||||
uint64_t now = usecTimestampNow();
|
||||
int elapsed = now - getLastEdited();
|
||||
qCDebug(entities) << "LightEntityItem::setProperties() AFTER update... edited AGO=" << elapsed <<
|
||||
"now=" << now << " getLastEdited()=" << getLastEdited();
|
||||
}
|
||||
setLastEdited(properties.getLastEdited());
|
||||
}
|
||||
return somethingChanged;
|
||||
}
|
||||
|
||||
|
||||
int LightEntityItem::readEntitySubclassDataFromBuffer(const unsigned char* data, int bytesLeftToRead,
|
||||
ReadBitstreamToTreeParams& args,
|
||||
EntityPropertyFlags& propertyFlags, bool overwriteLocalData,
|
||||
|
@ -193,3 +202,8 @@ void LightEntityItem::appendSubclassData(OctreePacketData* packetData, EncodeBit
|
|||
APPEND_ENTITY_PROPERTY(PROP_CUTOFF, getCutoff());
|
||||
APPEND_ENTITY_PROPERTY(PROP_FALLOFF_RADIUS, getFalloffRadius());
|
||||
}
|
||||
|
||||
void LightEntityItem::somethingChangedNotification() {
|
||||
EntityItem::somethingChangedNotification();
|
||||
_lightPropertiesChanged = false;
|
||||
}
|
||||
|
|
|
@ -31,9 +31,16 @@ public:
|
|||
/// set dimensions in domain scale units (0.0 - 1.0) this will also reset radius appropriately
|
||||
virtual void setDimensions(const glm::vec3& value) override;
|
||||
|
||||
virtual bool setProperties(const EntityItemProperties& properties) override;
|
||||
virtual bool setSubClassProperties(const EntityItemProperties& properties) override;
|
||||
|
||||
// methods for getting/setting all properties of an entity
|
||||
virtual EntityItemProperties getProperties(EntityPropertyFlags desiredProperties = EntityPropertyFlags()) const override;
|
||||
virtual bool setProperties(const EntityItemProperties& properties) override;
|
||||
|
||||
/// Override this in your derived class if you'd like to be informed when something about the state of the entity
|
||||
/// has changed. This will be called with properties change or when new data is loaded from a stream
|
||||
/// Overriding this function to capture the information that a light properties has changed
|
||||
virtual void somethingChangedNotification() override;
|
||||
|
||||
virtual EntityPropertyFlags getEntityProperties(EncodeBitstreamParams& params) const override;
|
||||
|
||||
|
@ -60,6 +67,7 @@ public:
|
|||
_color[RED_INDEX] = value.red;
|
||||
_color[GREEN_INDEX] = value.green;
|
||||
_color[BLUE_INDEX] = value.blue;
|
||||
_lightPropertiesChanged = true;
|
||||
}
|
||||
|
||||
bool getIsSpotlight() const { return _isSpotlight; }
|
||||
|
@ -69,13 +77,19 @@ public:
|
|||
void setIgnoredAttenuation(float value) { }
|
||||
|
||||
float getIntensity() const { return _intensity; }
|
||||
void setIntensity(float value) { _intensity = value; }
|
||||
void setIntensity(float value) {
|
||||
_intensity = value;
|
||||
_lightPropertiesChanged = true;
|
||||
}
|
||||
|
||||
float getFalloffRadius() const { return _falloffRadius; }
|
||||
void setFalloffRadius(float value);
|
||||
|
||||
float getExponent() const { return _exponent; }
|
||||
void setExponent(float value) { _exponent = value; }
|
||||
void setExponent(float value) {
|
||||
_exponent = value;
|
||||
_lightPropertiesChanged = true;
|
||||
}
|
||||
|
||||
float getCutoff() const { return _cutoff; }
|
||||
void setCutoff(float value);
|
||||
|
@ -85,6 +99,7 @@ public:
|
|||
|
||||
protected:
|
||||
|
||||
|
||||
// properties of a light
|
||||
rgbColor _color;
|
||||
bool _isSpotlight { DEFAULT_IS_SPOTLIGHT };
|
||||
|
@ -93,6 +108,11 @@ protected:
|
|||
float _exponent { DEFAULT_EXPONENT };
|
||||
float _cutoff { DEFAULT_CUTOFF };
|
||||
|
||||
// Dirty flag turn true when either light properties is changing values.
|
||||
// THis gets back to false in the somethingChangedNotification() call
|
||||
// Which is called after a setProperties() or a readEntitySubClassFromBUfferCall on the entity.
|
||||
bool _lightPropertiesChanged { false };
|
||||
|
||||
static bool _lightsArePickable;
|
||||
};
|
||||
|
||||
|
|
|
@ -22,7 +22,8 @@ bool nsightActive() {
|
|||
}
|
||||
|
||||
ProfileRange::ProfileRange(const char *name) {
|
||||
_rangeId = nvtxRangeStart(name);
|
||||
//_rangeId = nvtxRangeStart(name);
|
||||
_rangeId = nvtxRangePush(name);
|
||||
}
|
||||
|
||||
ProfileRange::ProfileRange(const char *name, uint32_t argbColor, uint64_t payload) {
|
||||
|
@ -36,11 +37,13 @@ ProfileRange::ProfileRange(const char *name, uint32_t argbColor, uint64_t payloa
|
|||
eventAttrib.payload.llValue = payload;
|
||||
eventAttrib.payloadType = NVTX_PAYLOAD_TYPE_UNSIGNED_INT64;
|
||||
|
||||
_rangeId = nvtxRangeStartEx(&eventAttrib);
|
||||
//_rangeId = nvtxRangeStartEx(&eventAttrib);
|
||||
_rangeId = nvtxRangePushEx(&eventAttrib);
|
||||
}
|
||||
|
||||
ProfileRange::~ProfileRange() {
|
||||
nvtxRangeEnd(_rangeId);
|
||||
// nvtxRangeEnd(_rangeId);
|
||||
nvtxRangePop();
|
||||
}
|
||||
|
||||
#else
|
||||
|
|
Loading…
Reference in a new issue