WeaponFireLight in 1.5.1
by Dusty Monk · in Torque Game Engine · 06/20/2007 (8:57 am) · 8 replies
The WeaponFireLight light type for lights on images doesn't appear to be working (at least for me), in 1.5.1. I haven't yet upgraded to 1.5.2, but I didn't see any mention of it in the release notes, so I'm assuming it has the same problems.
I set the light type to ConstantType, and verified that the light does get registered correctly and is visible in that mode. It's just WeaponFireLight that doesn't work.
I spent about 2 hours this morning trying to sort it out, and I haven't quite puzzled it out, but here's what I learned. Apparently the problem is in ShapeBase::MountedImage::registerImageLights, where it tries to set the light's intensity based on the delta time over the image data blocks's light time. Here's the code:
delta is calculated from the starttime passed in, which comes from mLightTime, which resides on the shapebase itself, that this array of images is associated with. The only time mLightTime is set is in in shapeBase::unpackeUpdate.. here...
I set a breakpoint here, and verified that indeed, when the weapon fires, the update is unpacked, and mLightTime is updated.
But setting a breakpoint in shapeBase::registerImageLights, mLightTime is *always* zero. That's when I figured out that its not even the same shapeBase being used in registerLights, that's being used in unpackUpdate. This led me to think that maybe server version of the player is being used to registerlights, but the client version of the player is the one that gets mLightTime updated. Does this make sense? Why would we be using the server version of the player to registerLights, which seems like strictly a client side thing.
In any event, if anyone that's more familiar with the engine could take a look, and verify whether or not it is (a) Yes, a problem, or (b) No, It's not a problem, I'm just insane, I would be greatly appreciative.
Some other nits..:
Using mLightTime, which sits on the shapebase itself, as the start time for the weaponfirelight duration, and comparing it to lightTime, which sits on the imagedata, means that you will never have more than a single image that is using WeaponFireLight that will work correctly. From what I can tell, the old code used to use a "lightStart" member of the mounted image structure defined inside shapebase, and this makes more sense, as it would allow a per image tacking of the weaponlight. But from what I can see, no where in the code is lightStart used or set anymore, except in getImageLight, which is also completely deprecated.
The comment for lightTime in ShapeBaseImageData is incorrect. It reads as follows:
That isn't the case. It's actually used as the *duration* for the light flash for WeaponFireLight. It's doubly confusing, because the variable mLightTime defined in shapeBase actually *does* appear to be used to indicate when the light was started.
Thanks in advance for thoughts or comments..
I set the light type to ConstantType, and verified that the light does get registered correctly and is visible in that mode. It's just WeaponFireLight that doesn't work.
I spent about 2 hours this morning trying to sort it out, and I haven't quite puzzled it out, but here's what I learned. Apparently the problem is in ShapeBase::MountedImage::registerImageLights, where it tries to set the light's intensity based on the delta time over the image data blocks's light time. Here's the code:
case ShapeBaseImageData::WeaponFireLight:
{
if (delta > dataBlock->lightTime)
return;
intensity = 1.0 - F32(delta) / F32(dataBlock->lightTime);
break;
}delta is calculated from the starttime passed in, which comes from mLightTime, which resides on the shapebase itself, that this array of images is associated with. The only time mLightTime is set is in in shapeBase::unpackeUpdate.. here...
if( imageData && imageData->lightType == ShapeBaseImageData::WeaponFireLight )
{
mLightTime = Sim::getCurrentTime();
}I set a breakpoint here, and verified that indeed, when the weapon fires, the update is unpacked, and mLightTime is updated.
But setting a breakpoint in shapeBase::registerImageLights, mLightTime is *always* zero. That's when I figured out that its not even the same shapeBase being used in registerLights, that's being used in unpackUpdate. This led me to think that maybe server version of the player is being used to registerlights, but the client version of the player is the one that gets mLightTime updated. Does this make sense? Why would we be using the server version of the player to registerLights, which seems like strictly a client side thing.
In any event, if anyone that's more familiar with the engine could take a look, and verify whether or not it is (a) Yes, a problem, or (b) No, It's not a problem, I'm just insane, I would be greatly appreciative.
Some other nits..:
Using mLightTime, which sits on the shapebase itself, as the start time for the weaponfirelight duration, and comparing it to lightTime, which sits on the imagedata, means that you will never have more than a single image that is using WeaponFireLight that will work correctly. From what I can tell, the old code used to use a "lightStart" member of the mounted image structure defined inside shapebase, and this makes more sense, as it would allow a per image tacking of the weaponlight. But from what I can see, no where in the code is lightStart used or set anymore, except in getImageLight, which is also completely deprecated.
The comment for lightTime in ShapeBaseImageData is incorrect. It reads as follows:
S32 lightTime; ///< Indicates the time when the light effect started.
///That isn't the case. It's actually used as the *duration* for the light flash for WeaponFireLight. It's doubly confusing, because the variable mLightTime defined in shapeBase actually *does* appear to be used to indicate when the light was started.
Thanks in advance for thoughts or comments..
About the author
Dusty Monk is founder and president of Windstorm Studios, an independant game studio. Formerly a sr. programmer at Ensemble Studios, Dusty has worked on AAA titles such as Age of Empires II & III, and Halo Wars.
#2
06/21/2007 (11:12 am)
All I can say is it doesn't work in TGEA 1.01. Sometimes it worked back in TGE version 1.x but other times it didn't. As you say, confusing results.
#3
I'm hoping someone on the team will take a look -- I suspect it's like a five minute fix for someone that's more familiar with the code.
06/21/2007 (1:09 pm)
Well I'm guessing that when they integrated the TLK in 1.5, they would have *had* to have changed some of it, as they pretty much changed how lights worked throughout the entire game. Maybe not. I haven't done a direct compare between 1.4 and 1.5 -- I supposed I should go and do that. I did see some of the earlier posts in 2005 that said it works in the single shot case only -- but i'm using a single shot case, have set it up according to the specs, and the light's pretty clearly not firing.I'm hoping someone on the team will take a look -- I suspect it's like a five minute fix for someone that's more familiar with the code.
#4
06/21/2007 (6:58 pm)
Make sure that stateFire[] is set to true for the particular state index of your Fire state, it seems that the WeaponFireLight needs it. That may not be the problem, so I'll look around more in the code for any problems.
#5
Chris, noted - we'll take a look at TGEA's weapon fire too.
Ross, good catch - I didn't realize that. It could explain the weird results.
06/22/2007 (1:44 pm)
Dale, TLK/TLS mainly changed light management and rendering code. It was designed to use Torque's existing LightInfo class, so the system didn't have to replace all code using or referencing lights.Chris, noted - we'll take a look at TGEA's weapon fire too.
Ross, good catch - I didn't realize that. It could explain the weird results.
#6
06/22/2007 (7:35 pm)
I see. Well FWIW I do in fact set the stateFire[] to true at the index in my state machine that is the fire state. I've not had a chance to dig into this further, as I'm pushing on with other things. But as it stands right now, it still doesn't appear to be working as advertised, at least.
#7
06/25/2007 (12:48 am)
I can't seem to replicate the issue. Would you be adverse to sending over your script so I may test it out on my end with what you are actually working with?
#8
06/25/2007 (1:16 am)
I've experienced this issue with different sized player models - the firelight stopped working with models that had a smaller scale. Increasing the size of the player caused the weapon fire light to begin working again.
Torque Owner John Kabus (BobTheCBuilder)
Is anyone else reading this running into a problem? I'd like to get a feel for what's going on.