[Plib-users] ref counting problem
Brought to you by:
sjbaker
From: McEvoy, N. <nic...@ds...> - 2003-01-20 11:08:58
|
I'm currently having some trouble with ref() counters in my PLIB game. My game contains a bunch of manager classes: - MaterialManager: creates/destroys materials (ie. ssgSimpleState) - ModelManager: creates/destroys models (ie. ssgEntity) - EntityManager: creates/destroys game entities (ie. ssgBranch) Each manager class calls ref() for each PLIB object it creates and ssgDeRefDelete() when it destroys the object. These classes are created & destroyed on loading and exiting levels in the game. The problem comes in my MaterialManager class that has a list of ssgSimpleState. The MaterialManager sets a ssgSetAppStateCallback() and thus supplies ssgSimpleState on loading AC3D Models. My problem is that I get an exception after loading and exiting different levels a few times ... it seems to be in ssgLoaderOptions::createLeaf() ... their seems to be shared_states with 'invalid' pointers (actually to be truthful I might be deleting the states when their ref() counters are not zero :-( ... before you say "well that's your problem" ... there is a reason for this ... I don't actually want the ssgSimpleState objects to hang around ... I know what I'm doing is wrong ... but I'm not quite sure what ssgLoaderOptions is doing ... why is it keeping the shared_states ? can I clear it ? or is my game logic all wrong ?). What should I do ? Should I really create/destroy my materials each level ... or should I load them ONCE only for the whole game ? Each level uses quite different materials ... so I would like to destroy them ... but I'm not quite sure what ssgLoaderOptions is doing hanging onto the states ? Any ideas ? Nick |