T3D Cripple performance when incorrectly inheriting PlayerData
by Kevin Mitchell · in Torque 3D Professional · 06/04/2013 (5:35 pm) · 11 replies
So recently I started code clean up and part of this was to consolidate player data to the DefaultPlayerData. When doing this I forgot to implement the line that changes the classname to the DefaultPlayerData. When loading up the system the first time the system crashed. I disabled all AI and the performance corrected. After stepping through some things I loaded only 10 AI players and the systems FPS decreased to 0.3. After finding the issue with the classname this fixed the issue and my FPS returned to 25-30.
Code difference example:
My question is this. Was this caused because of callbacks failing to find the call back? If so, if there are other call backs that I do not have a prototype for can this affect performance as heavily as well? Is there no way to know when it fails and for what callback function?
Code difference example:
datablock RPGPlayerData( ToriData : DefaultPlayerData )
{
shapeFile = "art/RPG_ENGINE/ArtElements/Actors/PlayableCharacters/Tori/Tori.dae";
DBname = "ToriData";
cameraMaxDist =4;
pickupRadius = "1";
airControl = "1";
minImpactSpeed = "50";
minLateralImpactSpeed = "50";
minJumpSpeed = "0";datablock RPGPlayerData( ToriData : DefaultPlayerData )
{
shapeFile = "art/RPG_ENGINE/ArtElements/Actors/PlayableCharacters/Tori/Tori.dae";
DBname = "ToriData";
cameraMaxDist =4;
className ="DefaultPlayerData";
pickupRadius = "1";
airControl = "1";
minImpactSpeed = "50";
minLateralImpactSpeed = "50";
minJumpSpeed = "0";My question is this. Was this caused because of callbacks failing to find the call back? If so, if there are other call backs that I do not have a prototype for can this affect performance as heavily as well? Is there no way to know when it fails and for what callback function?
About the author
Riding Solo since 2005. Current Project: Fated World 2005-Present RPG Engine Tool Kit - Now available.
#2
I assume that DefaultPlayerData is derived form PlayerData, so when adding a DefaultPlayerDate it uses PlayerData::onAdd when there is no DefaultPlayerData.
Also when you want to use a DefaultPlayerData::onAdd then you have to add
class = "DefaultPlayerData";
instead of className = DefaultPlayerData; to the DefaultPlayerData datablock.
06/05/2013 (6:06 am)
I think you need a function RPGPlayerData::onAdd or use the PlayerData::onAdd.I assume that DefaultPlayerData is derived form PlayerData, so when adding a DefaultPlayerDate it uses PlayerData::onAdd when there is no DefaultPlayerData.
Also when you want to use a DefaultPlayerData::onAdd then you have to add
class = "DefaultPlayerData";
instead of className = DefaultPlayerData; to the DefaultPlayerData datablock.
#3
But my main concern is does the system start throwing invisible errors when the call back is not defined via script. If so do i need to make sure that i make an instance of every call back to make sure the system does not have any performance issues just because I did not define a call back it is looking for.
06/05/2013 (6:17 am)
I had this defined I just forgot to include the class name.But my main concern is does the system start throwing invisible errors when the call back is not defined via script. If so do i need to make sure that i make an instance of every call back to make sure the system does not have any performance issues just because I did not define a call back it is looking for.
#4
06/05/2013 (6:19 am)
When I get home I'm going to try an experiment. I'm going to make a new call back and call it every time the system enters the update move and if the system slows down the this will show me that this would be an issue.
#5
06/05/2013 (6:48 am)
I'm very interested in the outcome, cause I'm experiencing also strange drops in fps, and I don't know where it comes from, so good luck and if you find something, please post it.
#6
If you have too many objects with that missing your game will just kill over and crash.
06/07/2013 (1:38 pm)
Rich, to follow up with this issue, it only happens when onAdd is removed. I make 3-4 call backs and placed them at random inside the player and AI player and did not see a FPS drop. It's crazy that it happened with that though. Good thing to take note of though. If you have too many objects with that missing your game will just kill over and crash.
#7
Thanks for making this thread :o)
08/27/2013 (4:49 am)
This is interesting. I kind of forgot to define this and just thought that I could use the default player::onAdd etc. without any action that define a new xxx::onAdd etc. callback function. I think this can one of the reasons my game crashes as more AIs or player characters are added. Definitely worth a try. Thanks for making this thread :o)
#8
08/28/2013 (3:42 pm)
Changing to PNG I take it did not fix the issue then?
#9
Currently it will lag like hell for a second or two(stutter lag etc.) or just CTD if three AIs are spawn and three player characters are already spawn or even crash from time to time.
If I try to spawn five models then the chance of avoiding ctd is 10 procent. Still with the same models. Perhaps the collision boxes in those models are bugged? But then again remove that enemy model and use another enemy model OR remove that player character model and use those very same enemy models and everything works like a charm o_O
Anyway I am not letting any callback functions be the bane of bugs showing up later during a player test so this is going to be investigated.
In the end as a final solution I might end up just not using those two models together :o)
08/28/2013 (4:12 pm)
No not really. It is still the same nasty should I crash or should I run thing :o) I am currently reading a lot about the class and className script class objects. It could be here that some missing callbacks make the engine crash as the number of AIs is spawn.Currently it will lag like hell for a second or two(stutter lag etc.) or just CTD if three AIs are spawn and three player characters are already spawn or even crash from time to time.
If I try to spawn five models then the chance of avoiding ctd is 10 procent. Still with the same models. Perhaps the collision boxes in those models are bugged? But then again remove that enemy model and use another enemy model OR remove that player character model and use those very same enemy models and everything works like a charm o_O
Anyway I am not letting any callback functions be the bane of bugs showing up later during a player test so this is going to be investigated.
In the end as a final solution I might end up just not using those two models together :o)
#10
Now I am not talking about creating more than one type of datablock is Torque Script. That is just a renaming of the same underlying C++ class.
08/28/2013 (4:57 pm)
I remember a long time ago that the datablock must match the object. I cannot remember why, but I seem to remember something on that. So this could very well be the issue you have been fighting. This is my vague recollection of the TGE days. I think I tried using a datablock made for a different class and there were issues.Now I am not talking about creating more than one type of datablock is Torque Script. That is just a renaming of the same underlying C++ class.
#11
The old books are still full of arcane knowledge :o)
This has to be tried out!!!
08/28/2013 (5:18 pm)
In fact I am just sitting here and reading about this very thing in the "The Game Programmer's Guide to Torque" by Edvard F. Maurina III on page 149-151 now. Lol :o)The old books are still full of arcane knowledge :o)
This has to be tried out!!!
Torque Owner Kevin Mitchell
12 CatBlack Studios
function DefaultPlayerData ::onAdd(%this,%obj)
If this happens the system slows to a crawl.
Maybe this call back is repeated until a successful execution?