Add SoftShadowRadius and Linearity to GLDEFS and A_AttachLight

This commit is contained in:
nashmuhandes 2025-05-18 02:08:37 +08:00
commit 051751220b
5 changed files with 45 additions and 3 deletions

View file

@ -1031,7 +1031,7 @@ DEFINE_ACTION_FUNCTION_NATIVE(AActor, A_AttachLightDef, AttachLightDef)
//
//==========================================================================
int AttachLightDirect(AActor *self, int _lightid, int type, int color, int radius1, int radius2, int flags, double ofs_x, double ofs_y, double ofs_z, double param, double spoti, double spoto, double spotp, double intensity)
int AttachLightDirect(AActor *self, int _lightid, int type, int color, int radius1, int radius2, int flags, double ofs_x, double ofs_y, double ofs_z, double param, double spoti, double spoto, double spotp, double intensity, double softshadowradius, double linearity)
{
FName lightid = FName(ENamedName(_lightid));
auto userlight = self->UserLights[FindUserLight(self, lightid, true)];
@ -1056,6 +1056,8 @@ int AttachLightDirect(AActor *self, int _lightid, int type, int color, int radiu
{
userlight->UnsetSpotPitch();
}
userlight->SetSoftShadowRadius(softshadowradius);
userlight->SetLinearity(linearity);
self->flags8 |= MF8_RECREATELIGHTS;
self->Level->flags3 |= LEVEL3_LIGHTCREATED;
return 1;
@ -1078,7 +1080,9 @@ DEFINE_ACTION_FUNCTION_NATIVE(AActor, A_AttachLight, AttachLightDirect)
PARAM_FLOAT(spoto);
PARAM_FLOAT(spotp);
PARAM_FLOAT(intensity);
ACTION_RETURN_BOOL(AttachLightDirect(self, lightid.GetIndex(), type, color, radius1, radius2, flags, ofs_x, ofs_y, ofs_z, parami, spoti, spoto, spotp, intensity));
PARAM_FLOAT(softshadowradius);
PARAM_FLOAT(linearity);
ACTION_RETURN_BOOL(AttachLightDirect(self, lightid.GetIndex(), type, color, radius1, radius2, flags, ofs_x, ofs_y, ofs_z, parami, spoti, spoto, spotp, intensity, softshadowradius, linearity));
}
//==========================================================================

View file

@ -121,6 +121,8 @@ public:
m_swapped = true;
}
}
void SetSoftShadowRadius(double r) { SoftShadowRadius = r; }
void SetLinearity(double i) { Linearity = i; }
protected:
FName m_Name = NAME_None;

View file

@ -82,6 +82,8 @@ FSerializer &Serialize(FSerializer &arc, const char *key, FLightDefaults &value,
("spotouter", value.m_spotOuterAngle)
("pitch", value.m_pitch)
("lightdefintensity", value.m_LightDefIntensity)
("softshadowradius", value.SoftShadowRadius)
("linearity", value.Linearity)
.EndObject();
}
return arc;

View file

@ -553,6 +553,8 @@ static const char *LightTags[]=
"trace",
"shadowminquality",
"intensity",
"softshadowradius",
"linearity",
nullptr
};
@ -582,6 +584,8 @@ enum {
LIGHTTAG_TRACE,
LIGHTTAG_SHADOW_MINQUALITY,
LIGHTTAG_INTENSITY,
LIGHTTAG_SOFTSHADOWRADIUS,
LIGHTTAG_LINEARITY,
};
//==========================================================================
@ -908,6 +912,12 @@ class GLDefsParser
case LIGHTTAG_INTENSITY:
defaults->SetLightDefIntensity(ParseFloat(sc));
break;
case LIGHTTAG_SOFTSHADOWRADIUS:
defaults->SetSoftShadowRadius(ParseFloat(sc));
break;
case LIGHTTAG_LINEARITY:
defaults->SetLinearity(ParseFloat(sc));
break;
default:
sc.ScriptError("Unknown tag: %s\n", sc.String);
}
@ -1019,6 +1029,12 @@ class GLDefsParser
case LIGHTTAG_INTENSITY:
defaults->SetLightDefIntensity(ParseFloat(sc));
break;
case LIGHTTAG_SOFTSHADOWRADIUS:
defaults->SetSoftShadowRadius(ParseFloat(sc));
break;
case LIGHTTAG_LINEARITY:
defaults->SetLinearity(ParseFloat(sc));
break;
default:
sc.ScriptError("Unknown tag: %s\n", sc.String);
}
@ -1133,6 +1149,12 @@ class GLDefsParser
case LIGHTTAG_INTENSITY:
defaults->SetLightDefIntensity(ParseFloat(sc));
break;
case LIGHTTAG_SOFTSHADOWRADIUS:
defaults->SetSoftShadowRadius(ParseFloat(sc));
break;
case LIGHTTAG_LINEARITY:
defaults->SetLinearity(ParseFloat(sc));
break;
default:
sc.ScriptError("Unknown tag: %s\n", sc.String);
}
@ -1246,6 +1268,12 @@ class GLDefsParser
case LIGHTTAG_INTENSITY:
defaults->SetLightDefIntensity(ParseFloat(sc));
break;
case LIGHTTAG_SOFTSHADOWRADIUS:
defaults->SetSoftShadowRadius(ParseFloat(sc));
break;
case LIGHTTAG_LINEARITY:
defaults->SetLinearity(ParseFloat(sc));
break;
default:
sc.ScriptError("Unknown tag: %s\n", sc.String);
}
@ -1356,6 +1384,12 @@ class GLDefsParser
case LIGHTTAG_INTENSITY:
defaults->SetLightDefIntensity(ParseFloat(sc));
break;
case LIGHTTAG_SOFTSHADOWRADIUS:
defaults->SetSoftShadowRadius(ParseFloat(sc));
break;
case LIGHTTAG_LINEARITY:
defaults->SetLinearity(ParseFloat(sc));
break;
default:
sc.ScriptError("Unknown tag: %s\n", sc.String);
}

View file

@ -1322,7 +1322,7 @@ class Actor : Thinker native
action native void A_OverlayTranslation(int layer, name trname);
native bool A_AttachLightDef(Name lightid, Name lightdef);
native bool A_AttachLight(Name lightid, int type, Color lightcolor, int radius1, int radius2, int flags = 0, Vector3 ofs = (0,0,0), double param = 0, double spoti = 10, double spoto = 25, double spotp = 0, double intensity = 1.0);
native bool A_AttachLight(Name lightid, int type, Color lightcolor, int radius1, int radius2, int flags = 0, Vector3 ofs = (0,0,0), double param = 0, double spoti = 10, double spoto = 25, double spotp = 0, double intensity = 1.0, double softshadowradius = 5.0, double linearity = 0.0);
native bool A_RemoveLight(Name lightid);
//================================================