How do the new 4.2.0 attached dynlights work?

Ask about ACS, DECORATE, ZScript, or any other scripting questions here!

Moderator: GZDoom Developers

Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.

Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
Post Reply
User avatar
Matt
Posts: 9696
Joined: Sun Jan 04, 2004 5:37 pm
Preferred Pronouns: They/Them
Operating System Version (Optional): Debian Bullseye
Location: Gotham City SAR, Wyld-Lands of the Lotus People, Dominionist PetroConfederacy of Saudi Canadia
Contact:

How do the new 4.2.0 attached dynlights work?

Post by Matt »

How do we attach them, remove them, define them, etc.?

If this is documented anywhere it should be linked in the wiki entry for [wiki]Dynamic light[/wiki].
Blue Shadow
Posts: 4949
Joined: Sun Nov 14, 2010 12:59 am

Re: How do the new 4.2.0 attached dynlights work?

Post by Blue Shadow »

There are functions. That's about all I know.
User avatar
Rip and Tear
Posts: 185
Joined: Tue May 02, 2017 3:54 pm

Re: How do the new 4.2.0 attached dynlights work?

Post by Rip and Tear »

I haven't been able to play around with it yet, but it seems like this doesn't allow for the same level of dynamic light manipulation as ZScript-defined lights. Not being able to add custom behavior to a light's tick makes this a no-go for my use case.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49071
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: How do the new 4.2.0 attached dynlights work?

Post by Graf Zahl »

If you want to custom-manipulate a light you'll have to call A_AttachLight with the same light ID repeatedly in the tick function. The lights themselves are now pure renderer side objects for performance reasons. The function allows changing all properties a light can have.
User avatar
Caligari87
Admin
Posts: 6174
Joined: Thu Feb 26, 2004 3:02 pm
Preferred Pronouns: He/Him
Contact:

Re: How do the new 4.2.0 attached dynlights work?

Post by Caligari87 »

Performance question then: In DarkDoomZ my flashlight works by having an inventory item spawn a dynamic light as a world actor since it sways and rotates somewhat independently of the player. Obviously with large radius lights and constant light movement, this leads to performance issues on maps with lots of linedefs, due to relinking I presume.

Would I gain any appreciable performance if I used an attached light on a dummy world actor or the player? Or is it going to be negligible in comparison to the movement relinking I presume will still be happening?

Link to my dynamic light class for reference

8-)
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49071
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: How do the new 4.2.0 attached dynlights work?

Post by Graf Zahl »

That won't make any difference. The light linking didn't get any faster with the change, the main advantage is that it doesn't require a full actor and all its overhead just to attach a light to a single state.
User avatar
Apeirogon
Posts: 1605
Joined: Mon Jun 12, 2017 12:57 am

Re: How do the new 4.2.0 attached dynlights work?

Post by Apeirogon »

So now I cant do

Code: Select all

class light : pointlight {}
in zscript file and need create light definition in gldefs and then constantly (re)attach it to actor? Am I right?

If no, tell me a way to create dynamically controlled dynamic light.
User avatar
Caligari87
Admin
Posts: 6174
Joined: Thu Feb 26, 2004 3:02 pm
Preferred Pronouns: He/Him
Contact:

Re: How do the new 4.2.0 attached dynlights work?

Post by Caligari87 »

Graf Zahl wrote:That won't make any difference. The light linking didn't get any faster with the change, the main advantage is that it doesn't require a full actor and all its overhead just to attach a light to a single state.
Thanks for the clarification! I suppose I'll leave it as-is, since a single actor isn't much overhead.

8-)
User avatar
22alpha22
Posts: 303
Joined: Fri Feb 21, 2014 5:04 pm
Graphics Processor: nVidia with Vulkan support
Location: Montana, USA

Re: How do the new 4.2.0 attached dynlights work?

Post by 22alpha22 »

Apeirogon wrote:So now I cant do

Code: Select all

class light : pointlight {}
in zscript file and need create light definition in gldefs and then constantly (re)attach it to actor? Am I right?

If no, tell me a way to create dynamically controlled dynamic light.
I'm pretty sure the old lights are sticking around, otherwise that would break compatibility with older mods which isn't something usually done.
User avatar
Matt
Posts: 9696
Joined: Sun Jan 04, 2004 5:37 pm
Preferred Pronouns: They/Them
Operating System Version (Optional): Debian Bullseye
Location: Gotham City SAR, Wyld-Lands of the Lotus People, Dominionist PetroConfederacy of Saudi Canadia
Contact:

Re: How do the new 4.2.0 attached dynlights work?

Post by Matt »

What's a lightid?
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49071
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: How do the new 4.2.0 attached dynlights work?

Post by Graf Zahl »

What it says on the plate. It's an identifier for the light, so you can call the function repeatedly on the same light. The number is maintained per actor and entirely in user space, i.e. it's you who decides what number to use.
User avatar
Matt
Posts: 9696
Joined: Sun Jan 04, 2004 5:37 pm
Preferred Pronouns: They/Them
Operating System Version (Optional): Debian Bullseye
Location: Gotham City SAR, Wyld-Lands of the Lotus People, Dominionist PetroConfederacy of Saudi Canadia
Contact:

Re: How do the new 4.2.0 attached dynlights work?

Post by Matt »

How are they defined then? Is there a light struct within the Actor class?
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49071
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: How do the new 4.2.0 attached dynlights work?

Post by Graf Zahl »

They are defined by calling A_AttachLight. Yes, there is a list of attached lights in each actor, and the lights in there are searched by the ID.
Post Reply

Return to “Scripting”