Only print the error for missing shadow caster once (closes #1594)

This commit is contained in:
Alexander Bock
2022-03-18 14:24:36 +01:00
parent 4e45f6634d
commit 1833894264
3 changed files with 18 additions and 5 deletions

View File

@@ -350,7 +350,7 @@ void AtmosphereDeferredcaster::preRaycast(const RenderData& data, const Deferred
// Shadow calculations..
_shadowDataArrayCache.clear();
for (const ShadowConfiguration& shadowConf : _shadowConfArray) {
for (ShadowConfiguration& shadowConf : _shadowConfArray) {
// TO REMEMBER: all distances and lengths in world coordinates are in
// meters!!! We need to move this to view space...
double lt;
@@ -374,10 +374,19 @@ void AtmosphereDeferredcaster::preRaycast(const RenderData& data, const Deferred
casterPos *= KM_TO_M; // converting to meters
SceneGraphNode* sourceNode = sceneGraphNode(shadowConf.source.first);
if (!sourceNode) {
if (!shadowConf.printedSourceError) {
LERROR("Invalid scenegraph node for the shadow's receiver");
shadowConf.printedSourceError = true;
}
return;
}
SceneGraphNode* casterNode = sceneGraphNode(shadowConf.caster.first);
if (!sourceNode || !casterNode) {
LERROR("Invalid scenegraph node for the shadow's caster or receiver");
if (!casterNode) {
if (!shadowConf.printedCasterError) {
LERROR("Invalid scenegraph node for the shadow's caster");
shadowConf.printedCasterError = true;
}
return;
}

View File

@@ -53,6 +53,10 @@ struct TransformData;
struct ShadowConfiguration {
std::pair<std::string, double> source;
std::pair<std::string, double> caster;
// Set to 'true' if we printed an error because we couldn't find the source or caster.
// We only want to print a message once
bool printedSourceError = false;
bool printedCasterError = false;
};
namespace documentation { struct Documentation; }