TL😃R; is there debug info I can force the spine-c runtime to output to help me figure this out? If not, read on. Crashing during animationstate_apply.
Hi there! I've been debugging this for awhile now to no avail, and I know I'm crashing during animationstate_apply
I've left the debug statements in in the below code, and the last thing printed before the crash is a "STATEUPD DONE.." line. The game has 10 or so enemies that get drawn atm, and every so often, the first time a LotusTurret is drawn, the game crashes. We haven't been able to discern what's unique about said LotusTurret that's causing our crash.
I've tried this both with a spine-c library compiled in December and one compiled today. I originally wrote this code before tracks existed, and modified it to just use the "first" track once they came into being. (I probably wrote this in the first place before October? but am no longer sure.)
In short, what I'm trying to do:
t (input param) is the current game time
lastUpdate (class member) is the game time as of last update
SPINESTATUS is an enum I use for signaling
it can be ignored here probably
GV::getAnnounceJams() returns whether or not the set of things we're drawing has been altered this frame; the crash is ALWAYS on the first time a specific unit type of ours is drawn.
the aniMap for a given spineDrawable contains the info about the current animation state, the next one, whether or not this state loops, and the string name for the state. The tracks bit of code there just asks if we should need to change the state, and, if so, does it. This code might no longer be a good idea
I think I wrote it, again, before there was anything in the spine-c runtime that did anything like it. Maybe I need to remove it?
The rest is just a series of calls to already-defined spine functions, and unless I'm calling them in the wrong order for some reason, should be straightforward. Again, our crash is happening during animationstate_apply.
Code's below
any help or suggestions about what else I should post would be greatly appreciated, as would info on a debug option for the spine-c library.
Cheers
SPINESTATUS SpineDrawable::update (float t) {
if (lastUpdate == 0.0f) {
//first update
lastUpdate = t;
}
//if (lastUpdate - t == 0) return SS_NONE;
if (GV::getAnnounceJams())
{
char str[200] = {0};
sprintf(str, "Spine LUSET" );
DebugLog::Log(str);
}
bool isComplete = false;
if (state->tracks[0] &&
(state->tracks[0]->time >= state->tracks[0]->endTime)
&& aniMap.at(aniState).loops == 0)
{
if (aniMap.at(aniState).nextState != ANISTATE_NULL) {
setState(aniMap.at(aniState).nextState);
}
if (GV::getAnnounceJams())
{
char str[200] = {0};
sprintf(str, "ANIMAP %4.2f %4.2f %01d %01d", state->tracks[0]->time, state->tracks[0]->endTime, state->tracks[0]->loop, aniMap.at(aniState).loops);
DebugLog::Log(str);
}
} else if (!state->tracks[0])
{
if (GV::getAnnounceJams()) DebugLog::Log("ERROR TRACKS0 NOT FOUND");
}
if (GV::getAnnounceJams())
{
char str[200] = {0};
sprintf(str, "ANIMAP %4.2f %4.2f %8.6f", t, lastUpdate, timeScale);
DebugLog::Log(str);
}
Skeleton_update(skeleton, (t - lastUpdate) * timeScale);
if (GV::getAnnounceJams())
{
char str[200] = {0};
sprintf(str, "SKELUPDATE DONE %d %d", state, skeleton);
DebugLog::Log(str);
}
AnimationState_update(state, (t - lastUpdate) * timeScale);
if (GV::getAnnounceJams())
{
char str[200] = {0};
sprintf(str, "STATEUPD DONE %d %d", state, skeleton);
DebugLog::Log(str);
}
AnimationState_apply(state, skeleton);
if (GV::getAnnounceJams())
{
char str[200] = {0};
sprintf(str, "STATEAPPL DONE %d %d", state, skeleton);
DebugLog::Log(str);
}
Skeleton_updateWorldTransform(skeleton);
if (GV::getAnnounceJams()) DebugLog::Log("SKELTRANS BIT DONE");
lastUpdate = t;
if (aniState == ANISTATE_DESTROY)
{
return SS_DESTROY;
}
if (GV::getAnnounceJams()) DebugLog::Log("DESTROYCHECK BIT DONE");
return SS_NONE;
}