From 03dbf52b432f074b0a99edcfbb5e948a97251967 Mon Sep 17 00:00:00 2001
From: = <eric@hellouser.net>
Date: Sat, 6 Apr 2013 23:59:56 -0500
Subject: [PATCH 1/2] Removing casting shadows from preview placement models,
still need to disable the model from receiving shadows.
---
source/graphics/Model.cpp | 12 ++++++++++++
source/graphics/Model.h | 2 ++
source/simulation2/components/CCmpTemplateManager.cpp | 3 +++
source/simulation2/components/CCmpVisualActor.cpp | 12 +++++++++++-
4 files changed, 28 insertions(+), 1 deletion(-)
diff --git a/source/graphics/Model.cpp b/source/graphics/Model.cpp
index b60fd1a..a82c855 100644
a
|
b
|
void CModel::AddFlagsRec(int flags)
|
602 | 602 | m_Props[i].m_Model->ToCModel()->AddFlagsRec(flags); |
603 | 603 | } |
604 | 604 | |
| 605 | void CModel::RemoveFlagsRec(int flags) |
| 606 | { |
| 607 | m_Flags &= ~flags; |
| 608 | |
| 609 | if (flags & MODELFLAG_IGNORE_LOS) |
| 610 | m_Material.AddShaderDefine("IGNORE_LOS", "1"); |
| 611 | |
| 612 | for (size_t i = 0; i < m_Props.size(); ++i) |
| 613 | if (m_Props[i].m_Model->ToCModel()) |
| 614 | m_Props[i].m_Model->ToCModel()->RemoveFlagsRec(flags); |
| 615 | } |
| 616 | |
605 | 617 | void CModel::SetMaterial(const CMaterial &material) |
606 | 618 | { |
607 | 619 | m_Material = material; |
diff --git a/source/graphics/Model.h b/source/graphics/Model.h
index 77e6224..6b3839b 100644
a
|
b
|
public:
|
118 | 118 | int GetFlags() const { return m_Flags; } |
119 | 119 | // add object flags, recursively through props |
120 | 120 | void AddFlagsRec(int flags); |
| 121 | // remove object flags, recursively through props |
| 122 | void RemoveFlagsRec(int flags); |
121 | 123 | |
122 | 124 | // recurse down tree setting dirty bits |
123 | 125 | virtual void SetDirtyRec(int dirtyflags) { |
diff --git a/source/simulation2/components/CCmpTemplateManager.cpp b/source/simulation2/components/CCmpTemplateManager.cpp
index e87e6a4..f3be24d 100644
a
|
b
|
void CCmpTemplateManager::CopyPreviewSubset(CParamNode& out, const CParamNode& i
|
525 | 525 | if (out.GetChild("Entity").GetChild("Obstruction").IsOk()) |
526 | 526 | CParamNode::LoadXMLString(out, "<Entity><Obstruction><Active>false</Active></Obstruction></Entity>"); |
527 | 527 | |
| 528 | if (out.GetChild("Entity").GetChild("VisualActor").IsOk()) |
| 529 | CParamNode::LoadXMLString(out, "<Entity><VisualActor><DisableShadows/></VisualActor></Entity>"); |
| 530 | |
528 | 531 | if (!corpse) |
529 | 532 | { |
530 | 533 | // Previews should always be visible in fog-of-war/etc |
diff --git a/source/simulation2/components/CCmpVisualActor.cpp b/source/simulation2/components/CCmpVisualActor.cpp
index b9a3088..ea91e07 100644
a
|
b
|
public:
|
117 | 117 | "<empty/>" |
118 | 118 | "</element>" |
119 | 119 | "</optional>" |
| 120 | "<optional>" |
| 121 | "<element name='DisableShadows' a:help='Used internally; if present, shadows will be disabled'>" |
| 122 | "<empty/>" |
| 123 | "</element>" |
| 124 | "</optional>" |
120 | 125 | "<element name='SilhouetteDisplay'>" |
121 | 126 | "<data type='boolean'/>" |
122 | 127 | "</element>" |
… |
… |
void CCmpVisualActor::InitModel(const CParamNode& paramNode)
|
535 | 540 | |
536 | 541 | if (paramNode.GetChild("SilhouetteDisplay").ToBool()) |
537 | 542 | modelFlags |= MODELFLAG_SILHOUETTE_DISPLAY; |
538 | | |
539 | 543 | if (paramNode.GetChild("SilhouetteOccluder").ToBool()) |
540 | 544 | modelFlags |= MODELFLAG_SILHOUETTE_OCCLUDER; |
541 | 545 | |
… |
… |
void CCmpVisualActor::InitModel(const CParamNode& paramNode)
|
544 | 548 | modelFlags |= MODELFLAG_IGNORE_LOS; |
545 | 549 | |
546 | 550 | model.ToCModel()->AddFlagsRec(modelFlags); |
| 551 | |
| 552 | if (paramNode.GetChild("DisableShadows").IsOk()) { |
| 553 | modelFlags = 0; |
| 554 | modelFlags |= MODELFLAG_CASTSHADOWS; |
| 555 | model.ToCModel()->RemoveFlagsRec(modelFlags); |
| 556 | } |
547 | 557 | } |
548 | 558 | |
549 | 559 | // Initialize the model's selection shape descriptor. This currently relies on the component initialization order; the |
--
1.7.10.4
From f532ca9148120f7e07d1a30fcffaceb762cf30db Mon Sep 17 00:00:00 2001
From: = <eric@hellouser.net>
Date: Sun, 7 Apr 2013 22:01:48 -0500
Subject: [PATCH 2/2] now preview placement models do not receive shadows
---
source/simulation2/components/CCmpVisualActor.cpp | 2 ++
1 file changed, 2 insertions(+)
diff --git a/source/simulation2/components/CCmpVisualActor.cpp b/source/simulation2/components/CCmpVisualActor.cpp
index ea91e07..8b8f89d 100644
a
|
b
|
void CCmpVisualActor::InitModel(const CParamNode& paramNode)
|
552 | 552 | if (paramNode.GetChild("DisableShadows").IsOk()) { |
553 | 553 | modelFlags = 0; |
554 | 554 | modelFlags |= MODELFLAG_CASTSHADOWS; |
| 555 | model.ToCModel()->GetMaterial().AddShaderDefine("USE_SHADOW", "false"); |
| 556 | model.ToCModel()->GetMaterial().AddShaderDefine("DISABLE_RECEIVE_SHADOWS", "1"); |
555 | 557 | model.ToCModel()->RemoveFlagsRec(modelFlags); |
556 | 558 | } |
557 | 559 | } |