add a custom max vertex lights in scene

This commit is contained in:
Crypto City 2023-08-02 06:44:12 +00:00
parent f402017686
commit fa2e8ea194
3 changed files with 12 additions and 3 deletions

View File

@ -346,7 +346,10 @@ void Drawable::LimitVertexLights(bool removeConvertedLights)
}
}
if (vertexLights_.Size() <= MAX_VERTEX_LIGHTS)
int max_vertex_lights = GetScene()->GetMaxVertexLights();
if (max_vertex_lights < 0)
max_vertex_lights = MAX_VERTEX_LIGHTS;
if (vertexLights_.Size() <= max_vertex_lights)
return;
const BoundingBox& box = GetWorldBoundingBox();
@ -354,7 +357,7 @@ void Drawable::LimitVertexLights(bool removeConvertedLights)
vertexLights_[i]->SetIntensitySortValue(box);
Sort(vertexLights_.Begin(), vertexLights_.End(), CompareDrawables);
vertexLights_.Resize(MAX_VERTEX_LIGHTS);
vertexLights_.Resize(max_vertex_lights);
}
void Drawable::OnNodeSet(Node* node)

View File

@ -69,7 +69,8 @@ Scene::Scene(Context* context) :
snapThreshold_(DEFAULT_SNAP_THRESHOLD),
updateEnabled_(true),
asyncLoading_(false),
threadedUpdate_(false)
threadedUpdate_(false),
maxVertexLights_(-1)
{
// Assign an ID to self so that nodes can refer to this node as a parent
SetID(GetFreeNodeID(REPLICATED));

View File

@ -283,6 +283,9 @@ public:
/// Mark a node dirty in scene replication states. The node does not need to have own replication state yet.
void MarkReplicationDirty(Node* node);
void SetMaxVertexLights(int max) { maxVertexLights_ = max; }
int GetMaxVertexLights() const { return maxVertexLights_; }
private:
/// Handle the logic update event to update the scene, if active.
void HandleUpdate(StringHash eventType, VariantMap& eventData);
@ -359,6 +362,8 @@ private:
bool asyncLoading_;
/// Threaded update flag.
bool threadedUpdate_;
int maxVertexLights_;
};
/// Register Scene library objects.