@@ -901,6 +901,12 @@ void Graphics::BuildMoveChildLists()
901901 if (!child || !child->ShouldDraw ())
902902 continue ;
903903
904+ if (auto childAnimating = child->GetBaseAnimating ())
905+ {
906+ if (childAnimating->IsViewModel () || !strcmp (" CTFViewModel" , child->GetClientClass ()->GetName ()))
907+ continue ;
908+ }
909+
904910 EHANDLE* moveparent = Entities::GetEntityProp<EHANDLE*>(child, " moveparent" );
905911 if (!moveparent || !moveparent->IsValid ())
906912 continue ;
@@ -911,28 +917,54 @@ void Graphics::BuildMoveChildLists()
911917 }
912918}
913919
920+ static Vector GetColorModulation ()
921+ {
922+ Vector color;
923+ render->GetColorModulation (color.Base ());
924+ return color;
925+ }
926+
914927void CGlowObjectManager::GlowObjectDefinition_t::DrawModel ()
915928{
916929 C_BaseEntity* const ent = m_hEntity.Get ();
917930 if (ent)
918931 {
919932 const auto & extra = Graphics::GetModule ()->FindExtraGlowData (m_hEntity.GetEntryIndex ());
933+ if (!extra)
934+ {
935+ PluginWarning (" Unable to find extra glow data for entity %i" , m_hEntity.GetEntryIndex ());
936+ return ;
937+ }
938+
939+ extra->ApplyGlowColor ();
940+ const auto initialColor = GetColorModulation ();
920941
921942 // Draw ourselves
922943 ent->DrawModel (STUDIO_RENDER);
944+ AssertMsg (initialColor == GetColorModulation (), " Color mismatch after drawing %s" , ent->GetClientClass ()->GetName ());
923945
924946 // Draw all move children
925947 for (auto moveChild : extra->m_MoveChildren )
948+ {
926949 moveChild->DrawModel (STUDIO_RENDER);
950+ AssertMsg (initialColor == GetColorModulation (), " Color mismatch after drawing %s" , moveChild->GetClientClass ()->GetName ());
951+ }
927952
928953 C_BaseEntity *pAttachment = ent->FirstMoveChild ();
929954 while (pAttachment != NULL )
930955 {
931956 if (pAttachment->ShouldDraw ())
957+ {
958+ // extra->ApplyGlowColor();
932959 pAttachment->DrawModel (STUDIO_RENDER);
960+ AssertMsg (initialColor == GetColorModulation (), " Color mismatch after drawing %s" , pAttachment->GetClientClass ()->GetName ());
961+ }
933962
934963 pAttachment = pAttachment->NextMovePeer ();
935964 }
965+
966+ // Did Valve "break" something?
967+ Assert (initialColor == GetColorModulation ());
936968 }
937969}
938970
@@ -956,17 +988,6 @@ void Graphics::DrawGlowAlways(int nSplitScreenSlot, CMatRenderContextPtr& pRende
956988 if (current.m_Base ->IsUnused () || !current.m_Base ->ShouldDraw (nSplitScreenSlot) || !current.m_Base ->m_bRenderWhenOccluded || !current.m_Base ->m_bRenderWhenUnoccluded )
957989 continue ;
958990
959- if (current.m_ShouldOverrideGlowColor )
960- {
961- Assert (current.m_GlowColorOverride .x >= 0 && current.m_GlowColorOverride .y >= 0 && current.m_GlowColorOverride .z >= 0 );
962- render->SetColorModulation (current.m_GlowColorOverride .Base ());
963- }
964- else
965- {
966- const Vector vGlowColor = current.m_Base ->m_vGlowColor * (current.m_Base ->m_flGlowAlpha * ce_graphics_glow_intensity.GetFloat ());
967- render->SetColorModulation (vGlowColor.Base ());
968- }
969-
970991 if (current.AnyInfillsActive ())
971992 {
972993 pRenderContext->SetStencilWriteMask (0xFFFFFFFF );
@@ -1067,17 +1088,6 @@ void Graphics::DrawGlowOccluded(int nSplitScreenSlot, CMatRenderContextPtr& pRen
10671088 if (current.m_Base ->IsUnused () || !current.m_Base ->ShouldDraw (nSplitScreenSlot) || !current.m_Base ->m_bRenderWhenOccluded || current.m_Base ->m_bRenderWhenUnoccluded )
10681089 continue ;
10691090
1070- if (current.m_ShouldOverrideGlowColor )
1071- {
1072- Assert (current.m_GlowColorOverride .x >= 0 && current.m_GlowColorOverride .y >= 0 && current.m_GlowColorOverride .z >= 0 );
1073- render->SetColorModulation (current.m_GlowColorOverride .Base ());
1074- }
1075- else
1076- {
1077- const Vector vGlowColor = current.m_Base ->m_vGlowColor * (current.m_Base ->m_flGlowAlpha * ce_graphics_glow_intensity.GetFloat ());
1078- render->SetColorModulation (vGlowColor.Base ());
1079- }
1080-
10811091 if (current.AnyInfillsActive ())
10821092 {
10831093 pRenderContext->SetStencilWriteMask (0xFFFFFFFF );
@@ -1110,17 +1120,6 @@ void Graphics::DrawGlowVisible(int nSplitScreenSlot, CMatRenderContextPtr& pRend
11101120 if (current.m_Base ->IsUnused () || !current.m_Base ->ShouldDraw (nSplitScreenSlot) || current.m_Base ->m_bRenderWhenOccluded || !current.m_Base ->m_bRenderWhenUnoccluded )
11111121 continue ;
11121122
1113- if (current.m_ShouldOverrideGlowColor )
1114- {
1115- Assert (current.m_GlowColorOverride .x >= 0 && current.m_GlowColorOverride .y >= 0 && current.m_GlowColorOverride .z >= 0 );
1116- render->SetColorModulation (current.m_GlowColorOverride .Base ());
1117- }
1118- else
1119- {
1120- const Vector vGlowColor = current.m_Base ->m_vGlowColor * (current.m_Base ->m_flGlowAlpha * ce_graphics_glow_intensity.GetFloat ());
1121- render->SetColorModulation (vGlowColor.Base ());
1122- }
1123-
11241123 if (current.AnyInfillsActive ())
11251124 {
11261125 pRenderContext->SetStencilWriteMask (0xFFFFFFFF );
@@ -1477,11 +1476,25 @@ Graphics::ExtraGlowData::ExtraGlowData(CGlowObjectManager::GlowObjectDefinition_
14771476
14781477bool Graphics::ExtraGlowData::AnyInfillsActive () const
14791478{
1480- for (const auto & infill : m_Infills)
1479+ Assert (m_Infills.size () == 2 );
1480+
1481+ return m_Infills[0 ].m_Active || m_Infills[1 ].m_Active ;
1482+ }
1483+
1484+ void Graphics::ExtraGlowData::ApplyGlowColor () const
1485+ {
1486+ if (m_ShouldOverrideGlowColor)
14811487 {
1482- if (infill.m_Active )
1483- return true ;
1488+ Assert (m_GlowColorOverride.x >= 0 && m_GlowColorOverride.y >= 0 && m_GlowColorOverride.z >= 0 );
1489+ Assert (m_GlowColorOverride.x < 1 || m_GlowColorOverride.y < 1 || m_GlowColorOverride.z < 1 );
1490+
1491+ render->SetColorModulation (m_GlowColorOverride.Base ());
14841492 }
1493+ else
1494+ {
1495+ const Vector vGlowColor = m_Base->m_vGlowColor * (m_Base->m_flGlowAlpha * GetModule ()->ce_graphics_glow_intensity .GetFloat ());
1496+ Assert (vGlowColor.x < 1 || vGlowColor.y < 1 || vGlowColor.z < 1 );
14851497
1486- return false ;
1498+ render->SetColorModulation (vGlowColor.Base ());
1499+ }
14871500}
0 commit comments