T3D 1.1 Beta3 - debrisShapeName causes hard engine crash due to bad pointer - RESOLVED (THREED-1565)
by Guy Allard · in Torque 3D Professional · 04/07/2011 (3:19 am) · 9 replies
Build: T3D 1.1 beta 3 pro (and probably earlier)
Platform: Windows Vista
Target: Game
Issues:
Assigning a debrisShapeName to the datablock for a ShapeBase derived object causes the engine to crash when the objects damage state == Destroyed and ShapeBase::blowUp() is invoked. This is due to Debris::prepRenderImage using a bad pointer.
Steps to repeat:
Assign a debrisShapeName to the datablock for a destroyable object, preferably a StaticShape (note, not player, as players override the normal shapebase damage state handling, and ShapeBase::blowUp() doesn't get called for them).
Destroy the object.
Watch the engine crash.
Suggested Fix:
in Debris.cpp, line 837, (debris::prepRenderImage)
change:
to:
Further info:
The (virtually undocumented) debrisShapeName field for ShapeBase derived objects is intended to allow the designer to be able to specify a shape which is broken up into its component parts when the object is destroyed. Each of these parts become a separate debris object, thereby allowing the designer to do things like have a robot or spacecraft break into flaming, smoking pieces, or have head, arms, legs and body fly around leaving trails of gibs behind.
The engine documentation for this field reads:
"The DTS or DAE model to use for auto-generated breakups. @note may not be functional."
The FPS example includes a debris shape file for the player in art/shapes/actors/common, and assigns it to the players datablock, but it doesn't actually get used because the player scripts override the normal ShapeBase damage state handling code.
After this fix debrisShapeName will be functional for destroyable shapes:
Platform: Windows Vista
Target: Game
Issues:
Assigning a debrisShapeName to the datablock for a ShapeBase derived object causes the engine to crash when the objects damage state == Destroyed and ShapeBase::blowUp() is invoked. This is due to Debris::prepRenderImage using a bad pointer.
Steps to repeat:
Assign a debrisShapeName to the datablock for a destroyable object, preferably a StaticShape (note, not player, as players override the normal shapebase damage state handling, and ShapeBase::blowUp() doesn't get called for them).
Destroy the object.
Watch the engine crash.
Suggested Fix:
in Debris.cpp, line 837, (debris::prepRenderImage)
change:
if( mPart ) mShape->setDetailFromDistance( state, dist * invScale );*this is the crash line, as if mPart is assigned, mShape will be null.
to:
if( mPart )
{
// get the shapeInstance that we are using for the debris parts
TSShapeInstance *si = mPart->getSourceShapeInstance();
// set the correct detail level
if( si )
si->setDetailFromDistance( state, dist * invScale );
}Further info:
The (virtually undocumented) debrisShapeName field for ShapeBase derived objects is intended to allow the designer to be able to specify a shape which is broken up into its component parts when the object is destroyed. Each of these parts become a separate debris object, thereby allowing the designer to do things like have a robot or spacecraft break into flaming, smoking pieces, or have head, arms, legs and body fly around leaving trails of gibs behind.
The engine documentation for this field reads:
"The DTS or DAE model to use for auto-generated breakups. @note may not be functional."
The FPS example includes a debris shape file for the player in art/shapes/actors/common, and assigns it to the players datablock, but it doesn't actually get used because the player scripts override the normal ShapeBase damage state handling code.
After this fix debrisShapeName will be functional for destroyable shapes:
About the author
Recent Threads
#2
There is a bit of 'documentation' on this feature in the Combat Starter Kit I worked on; specifically the vehicles and their destruction and subsequent 'explosion/debrisFling'/::Blowup[whisper in my ear a tad more of this code,TribesII players had it, love to see T3D have it as well...].
With the various builds of IA T3D....so many of these kinds of 'basic functionality destruction' bugs got introduced to the codeBase...I'll say it again as in irc....'gives me the shivers'.
...you are my new Hero, Guy, I mean it! ...and not just because of your avatar....!!
BTW: 'Damage' is also another "AWESOME" feature, hardly documented or a full exposure tutorial given....but digging for about ?? how many years now on 'Torque' brand products has given me a bit of 'insight', shall we say...."GET OUT", FTW![reference to the CSK HGT vehicle IFL 'damage' sequence of a screenshot of a group chat client interface I used as background on the vehicles 'monitors']...that was sweet. If you look closely enough on the artwork[monitor's bitmap material']...you'll see my avatar in the client's interface...along with the rest of the CSK Team.
04/07/2011 (6:39 am)
Thank you very much Guy.....;).There is a bit of 'documentation' on this feature in the Combat Starter Kit I worked on; specifically the vehicles and their destruction and subsequent 'explosion/debrisFling'/::Blowup[whisper in my ear a tad more of this code,TribesII players had it, love to see T3D have it as well...].
With the various builds of IA T3D....so many of these kinds of 'basic functionality destruction' bugs got introduced to the codeBase...I'll say it again as in irc....'gives me the shivers'.
...you are my new Hero, Guy, I mean it! ...and not just because of your avatar....!!
BTW: 'Damage' is also another "AWESOME" feature, hardly documented or a full exposure tutorial given....but digging for about ?? how many years now on 'Torque' brand products has given me a bit of 'insight', shall we say...."GET OUT", FTW![reference to the CSK HGT vehicle IFL 'damage' sequence of a screenshot of a group chat client interface I used as background on the vehicles 'monitors']...that was sweet. If you look closely enough on the artwork[monitor's bitmap material']...you'll see my avatar in the client's interface...along with the rest of the CSK Team.
#3
Being able to have aircraft or vehicles literally fall apart when destroyed looks great. For that to work, the dts (or dae) used for the debris pieces must be set up with the correct hierarchy in order for it to be fragmented, otherwise it will just act as a normal single piece of debris (and not crash).
art/shapes/actors/common/debris_player.dts in the fps example has the correct hierarchy to work with the auto breakup stuff.
04/07/2011 (7:52 am)
I think its a really cool feature, and am surprised there's so little mention of it. Being able to have aircraft or vehicles literally fall apart when destroyed looks great. For that to work, the dts (or dae) used for the debris pieces must be set up with the correct hierarchy in order for it to be fragmented, otherwise it will just act as a normal single piece of debris (and not crash).
art/shapes/actors/common/debris_player.dts in the fps example has the correct hierarchy to work with the auto breakup stuff.
#4
04/07/2011 (8:24 am)
Logged as THREED-1565.
#5
04/07/2011 (9:34 am)
Heh, I'd forgotten about the blow up into chunks feature. Nice find & fix Guy!
#6
...pretty sure, all you need for a 'exploding' object is a node for each piece of geometry you want tossed...engine does the rest. I don't remember having to have all my 'geometry' object nodes at world origin...I'd have to go back and look thru the CSK asset tree.
04/07/2011 (2:01 pm)
and...if I'm not mistaken, that player_debris.dts may be from TribesII...those players exploded if you crashed the flying vehicles. The geometry looks vaguely familiar; curse of a good memory, ;).--just swap skins for differing team of player object...heh-heh, I always appreciate a good lever....pretty sure, all you need for a 'exploding' object is a node for each piece of geometry you want tossed...engine does the rest. I don't remember having to have all my 'geometry' object nodes at world origin...I'd have to go back and look thru the CSK asset tree.
#7
04/13/2011 (5:52 pm)
Fixed in 1.1 Final.
#8
05/04/2012 (4:17 am)
What exactly does fixed mean? I just checked in a 1.2 codeBase and could not get the player object to 'blowUP'?
#9
05/04/2012 (9:45 am)
I'm thinking that 'fixed' means the nasty crash causing bad pointer issue was fixed. The player class just needs a little extra help in order to make use of the shapebase blowUp() feature since it (the player) overrides the inherited damage state sequences.
Associate Steve Acaster
[YorkshireRifles.com]
Figured I had a bad copy/paste though there was no warning/error messages in the console.