TorqueObject .MarkForDelete - Cannot mark object for delete
by Philip Loyer · in Torque X 2D · 03/21/2008 (5:14 pm) · 3 replies
TorqueObject .MarkForDelete - Cannot mark object for delete if not added to database
is anyone familiar with this error? I have not removed on unregistered any objects
is anyone familiar with this error? I have not removed on unregistered any objects
About the author
#2
Let me explain kinda of wahts going on here in detail. I have a tetrix like game that when three pieces drop to make a set it dissappears and works fine, however when another three pieces drop in the same place with the same color I get that error message. As one object is falling it is set as the playerObject, when it collides i remove that from being the player object and create a new object to start falling and Register it wirth the Torque database with this piece of code.
// clone the template to create the player object
_currentTriangle = (T2DSceneObject)triangleTemplate.Clone();
// place the player object
_currentTriangle.Position = new Microsoft.Xna.Framework.Vector2(0, -50);
// register our player with the TorqueObjectDatabase
TorqueObjectDatabase.Instance.Register(_currentTriangle);
And for some reason when i put a set in the place of a previous set with diffirent colors it confuses one of the objects colors with the previous ones colors in the TorqueObjectDatabase. Let me see if I can get the stack trace for you here.
at System.Environment.GetStackTrace(Exception e, Boolean needFileInfo)\r\n at System.Environment.get_StackTrace()\r\n at StarterGame2D.TriangleComponent.DeleteObject(T2DSceneObject thisObject) in C:\\Documents and Settings\\Phil\\My Documents\\Visual Studio 2005\\Projects\\Triangulation\\Triangulation\\Game\\Components\\TriangleComponent.cs:line 408\r\n at StarterGame2D.TriangleComponent.TestCollision(T2DSceneObject ourObject) in C:\\Documents and Settings\\Phil\\My Documents\\Visual Studio 2005\\Projects\\Triangulation\\Triangulation\\Game\\Components\\TriangleComponent.cs:line 339\r\n at StarterGame2D.TriangleComponent._ResolveCollision(T2DSceneObject ourObject, T2DSceneObject theirObject, T2DCollisionInfo& info, T2DCollisionMaterial physicsMaterial, Boolean handleBoth) in C:\\Documents and Settings\\Phil\\My Documents\\Visual Studio 2005\\Projects\\Triangulation\\Triangulation\\Game\\Components\\TriangleComponent.cs:line 224\r\n at GarageGames.Torque.T2D.T2DPhysicsComponent._ResolveCollisions(List'1 list) in C:\\Documents and Settings\\Phil\\My Documents\\Visual Studio 2005\\Projects\\Triangulation\\Triangulation\\Torque\\T2DComponents\\T2DPhysicsComponent.cs:line 595\r\n at GarageGames.Torque.T2D.T2DPhysicsComponent.ProcessTick(Move move, Single dt) in C:\\Documents and Settings\\Phil\\My Documents\\Visual Studio 2005\\Projects\\Triangulation\\Triangulation\\Torque\\T2DComponents\\T2DPhysicsComponent.cs:line 426\r\n at GarageGames.Torque.Sim.ProcessList._TickObjects(Single tickSec) in C:\\Documents and Settings\\Phil\\My Documents\\Visual Studio 2005\\Projects\\Triangulation\\Triangulation\\Torque\\Sim\\ProcessList.cs:line 698\r\n at GarageGames.Torque.Sim.ProcessList.AdvanceTick(Single floatMS) in C:\\Documents and Settings\\Phil\\My Documents\\Visual Studio 2005\\Projects\\Triangulation\\Triangulation\\Torque\\Sim\\ProcessList.cs:line 500\r\n at GarageGames.Torque.XNA.TorqueEngineComponent._UpdateSim(String eventName, Single elapsed) in C:\\Documents and Settings\\Phil\\My Documents\\Visual Studio 2005\\Projects\\Triangulation\\Triangulation\\Torque\\XNA\\TorqueEngineComponent.cs:line 781\r\n at GarageGames.Torque.Core.TorqueEvent'1._Trigger(Delegate d) in C:\\Documents and Settings\\Phil\\My Documents\\Visual Studio 2005\\Projects\\Triangulation\\Triangulation\\Torque\\Core\\TorqueEvent.cs:line 74\r\n at GarageGames.Torque.Core.TorqueEventManager._TriggerEvent(TorqueEventBase ev) in C:\\Documents and Settings\\Phil\\My Documents\\Visual Studio 2005\\Projects\\Triangulation\\Triangulation\\Torque\\Core\\TorqueEvent.cs:line 583\r\n at GarageGames.Torque.Core.TorqueEventManager.MgrProcessEvents() in C:\\Documents and Settings\\Phil\\My Documents\\Visual Studio 2005\\Projects\\Triangulation\\Triangulation\\Torque\\Core\\TorqueEvent.cs:line 434\r\n at GarageGames.Torque.Core.TorqueEventManager.ProcessEvents() in C:\\Documents and Settings\\Phil\\My Documents\\Visual Studio 2005\\Projects\\Triangulation\\Triangulation\\Torque\\Core\\TorqueEvent.cs:line 288\r\n at GarageGames.Torque.XNA.TorqueEngineComponent.Update(GameTime gameTime) in C:\\Documents and Settings\\Phil\\My Documents\\Visual Studio 2005\\Projects\\Triangulation\\Triangulation\\Torque\\XNA\\TorqueEngineComponent.cs:line 433\r\n at Microsoft.Xna.Framework.Game.Update(GameTime gameTime)\r\n at Microsoft.Xna.Framework.Game.Tick()\r\n at Microsoft.Xna.Framework.Game.HostIdle(Object sender, EventArgs e)\r\n at Microsoft.Xna.Framework.GameHost.OnIdle()\r\n at Microsoft.Xna.Framework.WindowsGameHost.ApplicationIdle(Object sender, EventArgs e)\r\n at System.Windows.Forms.Application.ThreadContext.System.Windows.Forms.UnsafeNativeMethods.IMsoComponent.FDoIdle(Int32 grfidlef)\r\n at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)\r\n at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)\r\n at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)\r\n at System.Windows.Forms.Application.Run(Form mainForm)\r\n at Microsoft.Xna.Framework.WindowsGameHost.Run()\r\n at Microsoft.Xna.Framework.Game.Run()\r\n at StarterGame2D.Game.Main() in C:\\Documents and Settings\\Phil\\My Documents\\Visual Studio 2005\\Projects\\Triangulation\\Triangulation\\Game\\Game.cs:line 86"
Thanks for the help John!
Phil
03/22/2008 (12:15 pm)
Well I am explicitly calling MarkForDelete on a object and it was created using the TorqueObjectDatabase.Instance.Register() method. Is there another to delete objects from the scene that I am not aware of? Let me explain kinda of wahts going on here in detail. I have a tetrix like game that when three pieces drop to make a set it dissappears and works fine, however when another three pieces drop in the same place with the same color I get that error message. As one object is falling it is set as the playerObject, when it collides i remove that from being the player object and create a new object to start falling and Register it wirth the Torque database with this piece of code.
// clone the template to create the player object
_currentTriangle = (T2DSceneObject)triangleTemplate.Clone();
// place the player object
_currentTriangle.Position = new Microsoft.Xna.Framework.Vector2(0, -50);
// register our player with the TorqueObjectDatabase
TorqueObjectDatabase.Instance.Register(_currentTriangle);
And for some reason when i put a set in the place of a previous set with diffirent colors it confuses one of the objects colors with the previous ones colors in the TorqueObjectDatabase. Let me see if I can get the stack trace for you here.
at System.Environment.GetStackTrace(Exception e, Boolean needFileInfo)\r\n at System.Environment.get_StackTrace()\r\n at StarterGame2D.TriangleComponent.DeleteObject(T2DSceneObject thisObject) in C:\\Documents and Settings\\Phil\\My Documents\\Visual Studio 2005\\Projects\\Triangulation\\Triangulation\\Game\\Components\\TriangleComponent.cs:line 408\r\n at StarterGame2D.TriangleComponent.TestCollision(T2DSceneObject ourObject) in C:\\Documents and Settings\\Phil\\My Documents\\Visual Studio 2005\\Projects\\Triangulation\\Triangulation\\Game\\Components\\TriangleComponent.cs:line 339\r\n at StarterGame2D.TriangleComponent._ResolveCollision(T2DSceneObject ourObject, T2DSceneObject theirObject, T2DCollisionInfo& info, T2DCollisionMaterial physicsMaterial, Boolean handleBoth) in C:\\Documents and Settings\\Phil\\My Documents\\Visual Studio 2005\\Projects\\Triangulation\\Triangulation\\Game\\Components\\TriangleComponent.cs:line 224\r\n at GarageGames.Torque.T2D.T2DPhysicsComponent._ResolveCollisions(List'1 list) in C:\\Documents and Settings\\Phil\\My Documents\\Visual Studio 2005\\Projects\\Triangulation\\Triangulation\\Torque\\T2DComponents\\T2DPhysicsComponent.cs:line 595\r\n at GarageGames.Torque.T2D.T2DPhysicsComponent.ProcessTick(Move move, Single dt) in C:\\Documents and Settings\\Phil\\My Documents\\Visual Studio 2005\\Projects\\Triangulation\\Triangulation\\Torque\\T2DComponents\\T2DPhysicsComponent.cs:line 426\r\n at GarageGames.Torque.Sim.ProcessList._TickObjects(Single tickSec) in C:\\Documents and Settings\\Phil\\My Documents\\Visual Studio 2005\\Projects\\Triangulation\\Triangulation\\Torque\\Sim\\ProcessList.cs:line 698\r\n at GarageGames.Torque.Sim.ProcessList.AdvanceTick(Single floatMS) in C:\\Documents and Settings\\Phil\\My Documents\\Visual Studio 2005\\Projects\\Triangulation\\Triangulation\\Torque\\Sim\\ProcessList.cs:line 500\r\n at GarageGames.Torque.XNA.TorqueEngineComponent._UpdateSim(String eventName, Single elapsed) in C:\\Documents and Settings\\Phil\\My Documents\\Visual Studio 2005\\Projects\\Triangulation\\Triangulation\\Torque\\XNA\\TorqueEngineComponent.cs:line 781\r\n at GarageGames.Torque.Core.TorqueEvent'1._Trigger(Delegate d) in C:\\Documents and Settings\\Phil\\My Documents\\Visual Studio 2005\\Projects\\Triangulation\\Triangulation\\Torque\\Core\\TorqueEvent.cs:line 74\r\n at GarageGames.Torque.Core.TorqueEventManager._TriggerEvent(TorqueEventBase ev) in C:\\Documents and Settings\\Phil\\My Documents\\Visual Studio 2005\\Projects\\Triangulation\\Triangulation\\Torque\\Core\\TorqueEvent.cs:line 583\r\n at GarageGames.Torque.Core.TorqueEventManager.MgrProcessEvents() in C:\\Documents and Settings\\Phil\\My Documents\\Visual Studio 2005\\Projects\\Triangulation\\Triangulation\\Torque\\Core\\TorqueEvent.cs:line 434\r\n at GarageGames.Torque.Core.TorqueEventManager.ProcessEvents() in C:\\Documents and Settings\\Phil\\My Documents\\Visual Studio 2005\\Projects\\Triangulation\\Triangulation\\Torque\\Core\\TorqueEvent.cs:line 288\r\n at GarageGames.Torque.XNA.TorqueEngineComponent.Update(GameTime gameTime) in C:\\Documents and Settings\\Phil\\My Documents\\Visual Studio 2005\\Projects\\Triangulation\\Triangulation\\Torque\\XNA\\TorqueEngineComponent.cs:line 433\r\n at Microsoft.Xna.Framework.Game.Update(GameTime gameTime)\r\n at Microsoft.Xna.Framework.Game.Tick()\r\n at Microsoft.Xna.Framework.Game.HostIdle(Object sender, EventArgs e)\r\n at Microsoft.Xna.Framework.GameHost.OnIdle()\r\n at Microsoft.Xna.Framework.WindowsGameHost.ApplicationIdle(Object sender, EventArgs e)\r\n at System.Windows.Forms.Application.ThreadContext.System.Windows.Forms.UnsafeNativeMethods.IMsoComponent.FDoIdle(Int32 grfidlef)\r\n at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)\r\n at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)\r\n at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)\r\n at System.Windows.Forms.Application.Run(Form mainForm)\r\n at Microsoft.Xna.Framework.WindowsGameHost.Run()\r\n at Microsoft.Xna.Framework.Game.Run()\r\n at StarterGame2D.Game.Main() in C:\\Documents and Settings\\Phil\\My Documents\\Visual Studio 2005\\Projects\\Triangulation\\Triangulation\\Game\\Game.cs:line 86"
Thanks for the help John!
Phil
#3
John K.
03/22/2008 (8:09 pm)
The stack trace shows a TriangleComponent._ResolveCollision... is there a KillCollision set as an event handler? If so, that could be deleting the object before you get a chance to set the MarkForDelete flag. If you want to email a code sample to me, I can take a closer look... it sounds like the TriangleComponent is where I need to look. I'll keep thinking about this - something doesn't sound right. Another thought - is it possible that you are deleting your template instead of your clone? John K.
Associate John Kanalakis
EnvyGames
John K.