Skip to content

Commit

Permalink
#219: Add TDM-specific support for noshadows_lit, since that is the s…
Browse files Browse the repository at this point in the history
…etting of most wall torches
  • Loading branch information
codereader committed Mar 26, 2022
1 parent 11bb1cd commit 85a6450
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
2 changes: 1 addition & 1 deletion radiantcore/entity/EntityNode.h
Expand Up @@ -138,7 +138,7 @@ class EntityNode :
virtual void foreachRenderable(const ObjectVisitFunction& functor) override;
virtual void foreachRenderableTouchingBounds(const AABB& bounds,
const ObjectVisitFunction& functor) override;
virtual bool isShadowCasting() const;
virtual bool isShadowCasting() const override;

// IMatrixTransform implementation
Matrix4 localToParent() const override { return _localToParent; }
Expand Down
20 changes: 18 additions & 2 deletions radiantcore/entity/eclassmodel/EclassModelNode.cpp
Expand Up @@ -12,7 +12,8 @@ EclassModelNode::EclassModelNode(const IEntityClassPtr& eclass) :
_angleKey(std::bind(&EclassModelNode::angleChanged, this)),
_angle(AngleKey::IDENTITY),
_renderOrigin(_origin),
_localAABB(Vector3(0,0,0), Vector3(1,1,1)) // minimal AABB, is determined by child bounds anyway
_localAABB(Vector3(0,0,0), Vector3(1,1,1)), // minimal AABB, is determined by child bounds anyway
_noShadowsLit(false)
{}

EclassModelNode::EclassModelNode(const EclassModelNode& other) :
Expand All @@ -24,7 +25,8 @@ EclassModelNode::EclassModelNode(const EclassModelNode& other) :
_angleKey(std::bind(&EclassModelNode::angleChanged, this)),
_angle(AngleKey::IDENTITY),
_renderOrigin(_origin),
_localAABB(Vector3(0,0,0), Vector3(1,1,1)) // minimal AABB, is determined by child bounds anyway
_localAABB(Vector3(0,0,0), Vector3(1,1,1)), // minimal AABB, is determined by child bounds anyway
_noShadowsLit(false)
{}

EclassModelNode::~EclassModelNode()
Expand All @@ -51,6 +53,7 @@ void EclassModelNode::construct()
observeKey("angle", sigc::mem_fun(_rotationKey, &RotationKey::angleChanged));
observeKey("rotation", sigc::mem_fun(_rotationKey, &RotationKey::rotationChanged));
observeKey("origin", sigc::mem_fun(_originKey, &OriginKey::onKeyValueChanged));
observeKey("noshadows_lit", sigc::mem_fun(this, &EclassModelNode::onNoshadowsLitChanged));
}

// Snappable implementation
Expand Down Expand Up @@ -188,6 +191,19 @@ void EclassModelNode::angleChanged()
updateTransform();
}

void EclassModelNode::onNoshadowsLitChanged(const std::string& value)
{
_noShadowsLit = value == "1";
}

bool EclassModelNode::isShadowCasting() const
{
// Both noShadowsLit and noShadows should be false
// It's hard to determine whether a compound entity like wall toches are starting
// in lit state, so we rather turn off shadow casting for them regardless of their state.
return !_noShadowsLit && EntityNode::isShadowCasting();
}

void EclassModelNode::onSelectionStatusChange(bool changeGroupStatus)
{
EntityNode::onSelectionStatusChange(changeGroupStatus);
Expand Down
5 changes: 5 additions & 0 deletions radiantcore/entity/eclassmodel/EclassModelNode.h
Expand Up @@ -47,6 +47,8 @@ class EclassModelNode :

AABB _localAABB;

bool _noShadowsLit;

private:
// Constructor
EclassModelNode(const IEntityClassPtr& eclass);
Expand Down Expand Up @@ -75,6 +77,8 @@ class EclassModelNode :

const Vector3& getWorldPosition() const override;

virtual bool isShadowCasting() const override;

protected:
// Gets called by the Transformable implementation whenever
// scale, rotation or translation is changed.
Expand Down Expand Up @@ -102,6 +106,7 @@ class EclassModelNode :
void originChanged();
void rotationChanged();
void angleChanged();
void onNoshadowsLitChanged(const std::string& value);
};

} // namespace

0 comments on commit 85a6450

Please sign in to comment.