Game Development Community

Particle Player Crashing

by Chase Webb · in Torque 2D Beginner · 09/03/2013 (1:39 am) · 33 replies

Hey all! I've been trying to add in my first ever particle player into my little game prototype, but it's causing me some problems. It's using essentially the same "ForceBubble" particle as the PointForceControllerToy, just cut down a tiny bit, but almost every time (emphasis on the almost, sometimes it works and lets me move around a bit before crashing) it crashes as soon as the program loads. Here is what is in my .cs script:

%player = new ParticlePlayer();
    %player.BodyType = static;
    %player.Position = %Position;
    %player.Particle = "GameAssets:ForceBubble";
    %player.SceneLayer = 0;
    MyScene.add( %player );

As you can see, nearly copy-paste from the PointForce Controller. Here's the .taml file for the particle effect:

<ParticleAsset
    AssetName="ForceBubble">
    <ParticleAssetEmitter
        EmitterName="MovingBubbles"
        Image="@asset=GameAssets:Particles5"
        Frame="1">
        <ParticleAssetEmitter.Fields>
            <Quantity>
				<Key Time="0" Value="0.2"/>
            </Quantity>
            <QuantityVariation>
				<Key Time="0" Value="0.1"/>
            </QuantityVariation>			
            <Lifetime>
				<Key Time="0" Value="5"/>
            </Lifetime>						
            <Speed>
				<Key Time="0" Value="0"/>
            </Speed>			
            <SizeX>
				<Key Time="0" Value="85.0"/>
            </SizeX>			
            <SizeXLife>
				<Key Time="0" Value="0.3"/>
				<Key Time="1" Value="1.0"/>
            </SizeXLife>			
            <AlphaChannel>
				<Key Time="0.0" Value="0.0"/>
				<Key Time="0.3" Value="0.2"/>
				<Key Time="0.9" Value="0.1"/>
				<Key Time="1.0" Value="0.0"/>				
			</AlphaChannel>
        </ParticleAssetEmitter.Fields>
    </ParticleAssetEmitter>	
</ParticleAsset>
Also worth noting is that even if I use an unedited version of the .taml file it crashes in the same manner.

Here is a screenshot of the crash in action:
[IMAGE]http://i.imgur.com/FU51Qx0.png[/IMAGE]
I know that this usually comes up when using things in infinitely small collision shapes, but I don't understand why that should be applying to this particle effect since it doesn't have one. It's definitely not anything else, as when this script is commented out the crashes stop. My log file doesn't show anything is wrong either, and it appears to create the object (in this case multiple of them at once during level generation) but does not crash until everything has finished loading.

Anyone have a guess as to what is going on here? :/
Page «Previous 1 2
#1
09/03/2013 (5:04 am)
A couple of questions:

1. Does it crash as soon as this line is executed: MyScene.add( %player ); ? If not, can you pinpoint the line where the crash occurs?

2. Which branch of the repo are you using?

3. Can you debug from the compiler to trace the stack? It would be useful to find out exactly where and what is crashing.
#2
09/03/2013 (6:58 am)
1. I'm honestly not sure at this point. Earlier I was able to get the players to load without immediately crashing on occasion, but at the moment it's crashing any time the MyScene.add( %player ); code isn't commented out.

2. I just updated to make sure I was using the latest development version, and the error still occurs.

3. I'm not sure how to do what you're asking. If you mean the log file when I run the debug version, here is the difference between the logs with the player code in, and with it commented out:
//-------------------------- 9/3/2013 -- 22:49:24 -----
Console trace is off.
Adding path expando of 'AppCore' as 'F:/Dropbox/ProtoBioGenesis/Prototypes/Protobiogenesis Prototype/modules/AppCore/1'.
--------------------------------------------------------------------------------
Video Initialization:
--------------------------------------------------------------------------------
Video initialization:
   Accelerated OpenGL display device detected.

Activating the OpenGL display device...
Activating the OpenGL display device...
Setting screen mode to 1024x768x32 (w)...
Creating a new window...
Acquiring a new device context...
Pixel format set:
  32 color bits, 24 depth bits, 8 stencil bits
Creating a new rendering context...
Making the new rendering context current...
OpenGL driver information:
  Vendor: ATI Technologies Inc.
  Renderer: AMD Radeon HD 7800 Series
  Version: 4.2.12002 Compatibility Profile Context 9.12.0.0
OpenGL Init: Enabled Extensions
  ARB_multitexture (Max Texture Units: 8)
  EXT_blend_color
  EXT_blend_minmax
  EXT_compiled_vertex_array
  EXT_texture_env_combine
  EXT_packed_pixels
  EXT_fog_coord
  ARB_texture_compression
  EXT_texture_compression_s3tc
  (ARB|EXT)_texture_env_add
  EXT_texture_filter_anisotropic (Max anisotropy: 16)
  WGL_EXT_swap_control
OpenGL Init: Disabled Extensions
  EXT_paletted_texture
  NV_vertex_array_range
  3DFX_texture_compression_FXT1

Max Texture Size reported as: 16384
OpenAL Driver Init
OpenAL Driver Init Success
Adding path expando of 'GameAssets' as 'F:/Dropbox/ProtoBioGenesis/Prototypes/Protobiogenesis Prototype/modules/GameAssets'.
(That was with the code)

This is with that line commented out (aka not crashing):
//-------------------------- 9/3/2013 -- 22:50:24 -----
Console trace is off.
Adding path expando of 'AppCore' as 'F:/Dropbox/ProtoBioGenesis/Prototypes/Protobiogenesis Prototype/modules/AppCore/1'.
--------------------------------------------------------------------------------
Video Initialization:
--------------------------------------------------------------------------------
Video initialization:
   Accelerated OpenGL display device detected.

Activating the OpenGL display device...
Activating the OpenGL display device...
Setting screen mode to 1024x768x32 (w)...
Creating a new window...
Acquiring a new device context...
Pixel format set:
  32 color bits, 24 depth bits, 8 stencil bits
Creating a new rendering context...
Making the new rendering context current...
OpenGL driver information:
  Vendor: ATI Technologies Inc.
  Renderer: AMD Radeon HD 7800 Series
  Version: 4.2.12002 Compatibility Profile Context 9.12.0.0
OpenGL Init: Enabled Extensions
  ARB_multitexture (Max Texture Units: 8)
  EXT_blend_color
  EXT_blend_minmax
  EXT_compiled_vertex_array
  EXT_texture_env_combine
  EXT_packed_pixels
  EXT_fog_coord
  ARB_texture_compression
  EXT_texture_compression_s3tc
  (ARB|EXT)_texture_env_add
  EXT_texture_filter_anisotropic (Max anisotropy: 16)
  WGL_EXT_swap_control
OpenGL Init: Disabled Extensions
  EXT_paletted_texture
  NV_vertex_array_range
  3DFX_texture_compression_FXT1

Max Texture Size reported as: 16384
OpenAL Driver Init
OpenAL Driver Init Success
Adding path expando of 'GameAssets' as 'F:/Dropbox/ProtoBioGenesis/Prototypes/Protobiogenesis Prototype/modules/GameAssets'.
Adding path expando of 'GameCore' as 'F:/Dropbox/ProtoBioGenesis/Prototypes/Protobiogenesis Prototype/modules/GameCore/5'.
Removing path expando of 'AppCore' as 'F:/Dropbox/ProtoBioGenesis/Prototypes/Protobiogenesis Prototype/modules/AppCore/1'.
Removing path expando of 'GameCore' as 'F:/Dropbox/ProtoBioGenesis/Prototypes/Protobiogenesis Prototype/modules/GameCore/5'.
Removing path expando of 'GameAssets' as 'F:/Dropbox/ProtoBioGenesis/Prototypes/Protobiogenesis Prototype/modules/GameAssets'.
Shutting down the OpenGL display device...
Making the GL rendering context not current...
Deleting the GL rendering context...
Releasing the device context...
#3
09/03/2013 (7:00 am)
It wouldn't let me add this too the end of my post (too many words in length), so here's the rest:


If you have any other directions for how I can help track this down it would be welcome. Just to confirm the same code within the PointForceControllerToy appears to be working. The only real difference between the two that I can think of is that PointForceControllerToy only loads one of these players, while my code is loading several (randomized 2-4 times within 9 areas upon the initial load, so 18-36 times in the above logs).
#4
09/03/2013 (5:18 pm)
Quote:
3. Can you debug from the compiler to trace the stack? It would be useful to find out exactly where and what is crashing.
You do this by debugging from within Visual Studio. It'll take a little research, but you should be able to narrow down your scene load anyway and then follow the breadcrumbs until you hit the crash. At that point you should have your stack and can follow it back up to find the source of the bad data.
#5
09/04/2013 (6:24 am)
I think my new main problem is that I cannot seem to get the debug program to run from within VS2012. Here is the output from the debugger every time:

pastebin.com/RfvfV3b4
#6
09/04/2013 (6:36 am)
Apparently the fix for my above problem was to go and change the settings to allow for some kind of symbol files to be downloaded from microsoft's servers? I've made progress towards being able to start debugging, but now I get this:

"Debugging information for 'torque2d_debug.exe' cannot be found or does not match. Cannot find or open the PDB file. Do you want to continue debugging?"

And if I click yes it's basically the same result as the pastebin above, but without the missing file errors for the other files. (It finishes without ever loading the program)
#7
09/04/2013 (6:44 am)
Sounds like there's something beyond Torque that's munged....
#8
09/05/2013 (4:37 am)
This is highly annoying. I can make a new test project in VS2012 and it will debug and run fine, but ANY of the Torque builds I have saved (four of them, since February) on my computer just refuse to load the debug program from within VS2012. I can build the debug program and run it separately with no problem.
#9
09/05/2013 (5:41 am)
Have you set your target directory for debugging?
#10
09/05/2013 (5:50 am)
I have no idea. Would that be under the Debug menu, Torqu2D Properties, and Working Directory? because that is set to $ProjectDir.

If you want to see the Output when I try to run Debug within VS2012 I made a support thread here: social.msdn.microsoft.com/Forums/vstudio/en-US/b4147e5b-493d-4ef5-8c34-d8f1aae6e...
#11
09/05/2013 (5:56 am)
When wanting to run Torque 2D under Visual Studio itself then you must change the working directory yourself to be the "TargetDir" and not the default of "ProjectDir".
#12
09/05/2013 (6:03 am)
SUCCESS!

Now to give the output panel for the original crash for the Particle Player:

pastebin.com/5vNWRt31
#13
09/05/2013 (6:07 am)
Put a breakpoint on line 115 in b2polygonshape.cpp. Once you hit that, start going up the stack until you find the object is responsible for the crash and get its properties.
#14
09/06/2013 (4:47 am)
This is my first time ever debugging before, so I'm not sure what to look for. I've managed to insert the break point and have a whole list of things under call stack:

>	Torque2D_DEBUG.exe!ComputeCentroid(const b2Vec2 * vs, int count) Line 115	C++
 	Torque2D_DEBUG.exe!b2PolygonShape::Set(const b2Vec2 * vertices, int count) Line 215	C++
 	Torque2D_DEBUG.exe!WorldQuery::QueryCallback(int proxyId) Line 738	C++
 	Torque2D_DEBUG.exe!b2DynamicTree::Query<WorldQuery>(WorldQuery * callback, const b2AABB & aabb) Line 188	C++
 	Torque2D_DEBUG.exe!WorldQuery::oobbQueryCircle(const Vector2 & centroid, const float radius) Line 447	C++
 	Torque2D_DEBUG.exe!WorldQuery::anyQueryCircle(const Vector2 & centroid, const float radius) Line 519	C++
 	Torque2D_DEBUG.exe!cScenepickCircle(Scene * object, int argc, const char * * argv) Line 2873	C++
 	Torque2D_DEBUG.exe!cScenepickCirclecaster(SimObject * object, int argc, const char * * argv) Line 2792	C++
 	Torque2D_DEBUG.exe!CodeBlock::exec(unsigned int ip, const char * functionName, Namespace * thisNamespace, unsigned int argc, const char * * argv, bool noCalls, const char * packageName, int setFrame) Line 1566	C++
 	Torque2D_DEBUG.exe!CodeBlock::exec(unsigned int ip, const char * functionName, Namespace * thisNamespace, unsigned int argc, const char * * argv, bool noCalls, const char * packageName, int setFrame) Line 1546	C++
 	Torque2D_DEBUG.exe!CodeBlock::exec(unsigned int ip, const char * functionName, Namespace * thisNamespace, unsigned int argc, const char * * argv, bool noCalls, const char * packageName, int setFrame) Line 1546	C++
 	Torque2D_DEBUG.exe!CodeBlock::exec(unsigned int ip, const char * functionName, Namespace * thisNamespace, unsigned int argc, const char * * argv, bool noCalls, const char * packageName, int setFrame) Line 1546	C++
 	Torque2D_DEBUG.exe!CodeBlock::exec(unsigned int ip, const char * functionName, Namespace * thisNamespace, unsigned int argc, const char * * argv, bool noCalls, const char * packageName, int setFrame) Line 1546	C++
 	Torque2D_DEBUG.exe!Namespace::Entry::execute(int argc, const char * * argv, ExprEvalState * state) Line 474	C++
 	Torque2D_DEBUG.exe!Con::execute(SimObject * object, int argc, const char * * argv, bool thisCallOnly) Line 1069	C++
 	Torque2D_DEBUG.exe!Con::executef(SimObject * object, int argc, ...) Line 1098	C++
 	Torque2D_DEBUG.exe!ModuleManager::loadModuleExplicit(const char * pModuleId, const unsigned int versionId) Line 795	C++
 	Torque2D_DEBUG.exe!cModuleManagerloadExplicit(ModuleManager * object, int argc, const char * * argv) Line 104	C++
 	Torque2D_DEBUG.exe!cModuleManagerloadExplicitcaster(SimObject * object, int argc, const char * * argv) Line 97	C++
 	Torque2D_DEBUG.exe!CodeBlock::exec(unsigned int ip, const char * functionName, Namespace * thisNamespace, unsigned int argc, const char * * argv, bool noCalls, const char * packageName, int setFrame) Line 1628	C++
 	Torque2D_DEBUG.exe!Namespace::Entry::execute(int argc, const char * * argv, ExprEvalState * state) Line 474	C++
 	Torque2D_DEBUG.exe!Con::execute(SimObject * object, int argc, const char * * argv, bool thisCallOnly) Line 1069	C++
 	Torque2D_DEBUG.exe!Con::executef(SimObject * object, int argc, ...) Line 1098	C++
 	Torque2D_DEBUG.exe!ModuleManager::loadModuleExplicit(const char * pModuleId, const unsigned int versionId) Line 795	C++
 	Torque2D_DEBUG.exe!cModuleManagerloadExplicit(ModuleManager * object, int argc, const char * * argv) Line 104	C++
 	Torque2D_DEBUG.exe!cModuleManagerloadExplicitcaster(SimObject * object, int argc, const char * * argv) Line 97	C++
 	Torque2D_DEBUG.exe!CodeBlock::exec(unsigned int ip, const char * functionName, Namespace * thisNamespace, unsigned int argc, const char * * argv, bool noCalls, const char * packageName, int setFrame) Line 1628	C++
 	Torque2D_DEBUG.exe!CodeBlock::compileExec(const char * fileName, const char * string, bool noCalls, int setFrame) Line 649	C++
 	Torque2D_DEBUG.exe!Con::evaluate(const char * string, bool echo, const char * fileName) Line 965	C++
 	Torque2D_DEBUG.exe!initializeGame(int argc, const char * * argv) Line 308	C++
 	Torque2D_DEBUG.exe!DefaultGame::mainInitialize(int argc, const char * * argv) Line 352	C++
 	Torque2D_DEBUG.exe!run(int argc, const char * * argv) Line 1567	C++
 	Torque2D_DEBUG.exe!WinMain(HINSTANCE__ * hInstance, HINSTANCE__ * __formal, char * lpszCmdLine, int __formal) Line 1677	C++
 	Torque2D_DEBUG.exe!__tmainCRTStartup() Line 238	C
 	kernel32.dll!@BaseThreadInitThunk@12()	Unknown
 	ntdll.dll!___RtlUserThreadStart@8()	Unknown
 	ntdll.dll!__RtlUserThreadStart@8()	Unknown

Where do I go from here?
#15
09/06/2013 (5:04 am)
Are you picking a circle anywhere?
#16
09/06/2013 (5:16 am)
I am, much earlier in the function, before the particle player is created.
#17
09/06/2013 (5:17 am)
Ok, you need to step then. Press F5 to continue debugging until you hit the crash, which contains the info you need.
#18
09/06/2013 (6:00 am)
Small update: I just tried to speed up the debugging process by significantly shrinking my world size (and thus the amount of world generated when the game loads). I hadn't realized I had left it at a value of 11 sectors by 11 sectors in an earlier test and never set it back to the original value of 3 by 3...

A little math: Each sector was a square of 400 by 400, which was then created for 11 by 11 sectors, meaning a total value of 4400 by 4400 of world was generating when I started the program. Each sector contains between 3 and 30 large rocks, 2-4 geyser sprites, and each of the geysers spews out a few bubbles a second (which have a 2 second lifetime - I plan on replacing them with a particle effect later). Also, the rocks and geysers do a PickCircle check to make sure there is nothing in the area where it wants to spawn before being added to the scene.

The above information is important for the following: when I reverted the amount of world generated to a mere 3 by 3 square of sectors upon the game loading it stopped crashing. Could I have reached some kind of upper limit on the number of objects the game can create/handle? I plan on implementing some kind of sleep/freeze/pause scripts for areas outside of the player's current position, but at the moment it was all just running wildly even when the player object wasn't around.

So.... should I assume my crash wasn't the particle player directly, but the result of adding the particle player to every geyser object causing the number of objects the engine was handling to overwhelm it?

Just in case, I'm going to try to reproduce the problem using nothing but rocks (with no particles attached) and see if I can make it crash again.
#19
09/06/2013 (6:37 pm)
Ok, I've managed to cut out (comment out) a TON of the world generation code and still manage to reproduce the crash. I ran the debugger, got the program to crash, and then pressed retry and copied the Stack Info to get this:

>	Torque2D_DEBUG.exe!_wassert(const wchar_t * expr, const wchar_t * filename, unsigned int lineno) Line 344	C
 	Torque2D_DEBUG.exe!ComputeCentroid(const b2Vec2 * vs, int count) Line 115	C++
 	Torque2D_DEBUG.exe!b2PolygonShape::Set(const b2Vec2 * vertices, int count) Line 215	C++
 	Torque2D_DEBUG.exe!WorldQuery::QueryCallback(int proxyId) Line 738	C++
 	Torque2D_DEBUG.exe!b2DynamicTree::Query<WorldQuery>(WorldQuery * callback, const b2AABB & aabb) Line 188	C++
 	Torque2D_DEBUG.exe!WorldQuery::oobbQueryAABB(const b2AABB & aabb) Line 360	C++
 	Torque2D_DEBUG.exe!WorldQuery::anyQueryAABB(const b2AABB & aabb) Line 465	C++
 	Torque2D_DEBUG.exe!PointForceController::integrate(Scene * pScene, const float totalTime, const float elapsedTime, DebugStats * pDebugStats) Line 118	C++
 	Torque2D_DEBUG.exe!Scene::processTick() Line 834	C++
 	Torque2D_DEBUG.exe!Tickable::advanceTime(unsigned int timeDelta) Line 109	C++
 	Torque2D_DEBUG.exe!DefaultGame::processTimeEvent(TimeEvent * event) Line 603	C++
 	Torque2D_DEBUG.exe!GameInterface::processEvent(Event * event) Line 95	C++
 	Torque2D_DEBUG.exe!GameInterface::processEvents() Line 165	C++
 	Torque2D_DEBUG.exe!DefaultGame::mainLoop() Line 459	C++
 	Torque2D_DEBUG.exe!run(int argc, const char * * argv) Line 1573	C++
 	Torque2D_DEBUG.exe!WinMain(HINSTANCE__ * hInstance, HINSTANCE__ * __formal, char * lpszCmdLine, int __formal) Line 1677	C++
 	Torque2D_DEBUG.exe!__tmainCRTStartup() Line 238	C
 	kernel32.dll!@BaseThreadInitThunk@12()	Unknown
 	ntdll.dll!___RtlUserThreadStart@8()	Unknown
 	ntdll.dll!__RtlUserThreadStart@8()	Unknown

Hopefully that's the right spot? The Call Stack window goes blank when the crash first appears, which is why I pressed retry.
#20
09/06/2013 (6:42 pm)
Oh, and before I forget, here is the code for the function that is causing the crash. I have also discovered that if I comment out EITHER the Particle Player OR the Point Force Controller the crashes stop happening.

function GameCore::createGeyser(%SectorX, %SectorY, %geysersize)
{

		%Geyser = new Sprite()

        {
            class = "Geyser";
        };
			
		%Position = getRandom(((%sectorX * $sectorsize) - $sectorsize/2),((%sectorX * $sectorsize) + $sectorsize/2)) SPC getRandom(((%sectorY * $sectorsize) - $sectorsize/2),((%sectorY * $sectorsize) + $sectorsize/2));
/*
		//Check for already existing object
		%PositionCheckFinished = 0;
		
		while(%PositionCheckFinished == 0){
		%PositionCheckFinished = 0;
		%objectconflict = false;
		
		%picked = MyScene.pickCircle( %Position, %geysersize * 0.7, -1, -1, any);
		
			%pickedcount = %picked.count;
			
			for( %variable=0; %variable<%pickedcount; %variable++ )
			{
			%object_ID = getWord(%picked, %variable);
			//echo("object_ID.SceneGroup is " SPC %object_ID.SceneGroup);
			//echo("object_ID.SceneLayer is " SPC %object_ID.SceneLayer);
			//if(%object_ID.SceneGroup != 31)  
			if(%object_ID.SceneLayer >= 5 && %object_ID.SceneLayer <= 29)
				{
				%objectconflict = true;
				}
			}


			if(%objectconflict == true){
			
			%Position = getRandom(((%sectorX * $sectorsize) - $sectorsize/2),((%sectorX * $sectorsize) + $sectorsize/2)) SPC getRandom(((%sectorY * $sectorsize) - $sectorsize/2),((%sectorY * $sectorsize) + $sectorsize/2));
		
			}else{
			%PositionCheckFinished = 1;
			}
}
	//End Check
*/
		
		%Geyser.Position = %Position;
		%Geyser.setBodyType( static );
		%Geyser.Size = %geysersize;
        %Geyser.Image = "GameAssets:Geyser";
		%Geyser.setBlendColor(255/255, 255/255, 255/255, 255/255);
		
		%Geyser.SectorX = %SectorX;
		%Geyser.SectorY = %SectorY;
		

        %Geyser.CShapeIndex = %Geyser.createCircleCollisionShape( %geysersize * 0.28 );
        
		%Geyser.DefaultCollisionLayers = bit(5)|bit(6)|bit(7)|bit(8)|bit(9)|bit(10);
		%Geyser.DefaultCollisionGroups = 1;
		%Geyser.DefaultSceneGroup = 30;
		%Geyser.DefaultSceneLayer = "27 28 29";
		
			//Rocks are the second layer of the environment to be rendered.
		%Geyser.EnvironmentLayer = 2;
		
		
		%Geyser.CollisionLayers=%Geyser.DefaultCollisionLayers;
		%Geyser.setCollisionGroups(%Geyser.DefaultCollisionGroups);
		%Geyser.SceneGroup = %Geyser.DefaultSceneGroup;
		%Geyser.SceneLayer = %Geyser.DefaultSceneLayer;

		%Geyser.setDefaultDensity( 5 );
		%Geyser.setDefaultRestitution( 0 );
		%Geyser.setDefaultFriction( 0 );
		
		%Geyser.CollisionCallback = true;
	    myScene.add( %Geyser );		





    // Create a new controller.
    %Geyser.controller = new PointForceController();
    %Geyser.controller.setControlLayers( "5 6 7 8 9 10 11" );
    %Geyser.controller.Radius = %geysersize * 3;
    %Geyser.controller.Force = -250;
    %Geyser.controller.NonLinear = true;
    %Geyser.controller.LinearDrag = 0.5;
    %Geyser.controller.AngularDrag = 0.5;
	%Geyser.controller.Position = %Geyser.GetWorldCenter();

	MyScene.Controllers.add( %Geyser.controller );
	
  // Create planetoid bubble.
    %player = new ParticlePlayer();
    %player.BodyType = static;
    %player.Position = %Geyser.GetWorldCenter();
    %player.Particle = "GameAssets:ForceBubble";
    %player.SceneLayer = 0;
    MyScene.add( %player );

	
	//GameCore::StreamGeyserBubbles(%Geyser);
	
	
	
	//echo("Geyser Added");
	return %Geyser;

}
Page «Previous 1 2