TP master system crashes R13 immediately

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 21/04/2012 at 11:19, xxxxxxxx wrote:

User Information:
Cinema 4D Version:   R13.051 
Platform:   Windows  ;   
Language(s) :     C++  ;

---------
I have no idea what's going on here, but every time I try and get the TP_MasterSystem of a scene, Cinema crashes straight away. This is my code and it's basically taken from the doc as is:

  
TP_MasterSystem* TPPartioData::GetTpMasterSystem(BaseDocument* doc)
{  
	if (!doc) {  
		GePrint("No TP Master found");  
		return NULL;  
		}
BaseSceneHook* hook = doc->FindSceneHook(ID_THINKINGPARTICLES);  
if(!hook || hook->GetType() != ID_THINKINGPARTICLES)  
{  
GePrint("No TP Master found");  
return NULL;  
}
TP_MasterSystem *tp = (TP_MasterSystem* )(hook); // this is ok  
tp->NumParticles(); // here it crashes with _any_ tp->.... related call  
GePrint("I made it here"); // sadly, not so  
return static_cast<TP_MasterSystem*>(hook);  
}

I'm compiling with VS2008 for 64bit.

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 21/04/2012 at 11:27, xxxxxxxx wrote:

Ok, I don't really understand why and what it does, but I found this in an old thread and after adding it before the tp calls, it works now?

if (!CheckLib(ID_THINKINGPARTICLES, LIBOFFSET(C4DLibrary_TPOS, MSYS), reinterpret_cast<C4DLibrary\*\*>(&TPOS)))   

{
GePrint("Checklib failed");
return FALSE;
}

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 21/04/2012 at 11:31, xxxxxxxx wrote:

I wonder if you put

  
    
    
    TP_MasterSystem *tp = (TP_MasterSystem* )(hook); 
if(!tp) return NULL;    
  

if that would prevent the crash?

give it a try and let me know.  :)

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 21/04/2012 at 15:01, xxxxxxxx wrote:

See InitThinkingParticles() in the SDK. You need to call this before TP is used (I'm just repeating the SDK when I say that!). I do it and don't have any problems with getting the TP master system.

Steve

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 21/04/2012 at 15:07, xxxxxxxx wrote:

I totally overlooked that! Thanks Steve