|
| Author |
Message |
|
migel
|
Post subject: Removing and creating entity Posted: Fri Nov 06, 2009 2:36 am |
| Veteran |
 |
Joined: Fri Apr 17, 2009 7:38 am Posts: 65 Location: Finland
|
Whats wrong with this (testing) code? Code: // Destroy old entity scene.RootSceneNode.DetachObject(ogreHead); scene.RemoveEntity("OgreHead"); ogreHead = null;
// Create new entity ogreHead = scene.CreateEntity("OgreHead", "ogrehead.mesh"); scene.RootSceneNode.AttachObject(ogreHead);
I tested this with CameraTrack.cs demo (copying it to OnFrameStarted -method). Demo stops in SubEntity.cs, line 641. This same problem occurs on YAT (tetris project, it removes and creates bricks again and again), so thats the why Im wondering this.
|
|
|
|
 |
|
andris11
|
Post subject: Re: Removing and creating entity Posted: Fri Nov 06, 2009 10:49 am |
Joined: Wed Mar 22, 2006 8:06 pm Posts: 622
|
|
Looks like a bug, what's the exception/stack trace and the Axiom package in use? (log should cover that)
|
|
|
|
 |
|
migel
|
Post subject: Re: Removing and creating entity Posted: Fri Nov 06, 2009 2:44 pm |
| Veteran |
 |
Joined: Fri Apr 17, 2009 7:38 am Posts: 65 Location: Finland
|
Im using newest crickhollow svn (on xp/w7) Quote: [09:41:23] Object reference not set to an instance of an object. at Axiom.Core.SubEntity.get_Lights() in F:\csharp\axiom_svn\trunk_orig\trunk\Projects\Axiom\Engine\Core\SubEntity.cs:line 643 at Axiom.Core.SceneManager.RenderSingleObject(IRenderable renderable, Pass pass, Boolean doLightIteration, LightList manualLightList) in F:\csharp\axiom_svn\trunk_orig\trunk\Projects\Axiom\Engine\Core\SceneManager.cs:line 5243 at Axiom.Core.SceneManager.RenderSolidObjects(SortedList list, Boolean doLightIteration, LightList manualLightList) in F:\csharp\axiom_svn\trunk_orig\trunk\Projects\Axiom\Engine\Core\SceneManager.cs:line 5420 at Axiom.Core.SceneManager.RenderSolidObjects(SortedList list, Boolean doLightIteration) in F:\csharp\axiom_svn\trunk_orig\trunk\Projects\Axiom\Engine\Core\SceneManager.cs:line 5428 at Axiom.Core.SceneManager.RenderBasicQueueGroupObjects(RenderQueueGroup group) in F:\csharp\axiom_svn\trunk_orig\trunk\Projects\Axiom\Engine\Core\SceneManager.cs:line 6022 at Axiom.Core.SceneManager.RenderQueueGroupObjects(RenderQueueGroup group) in F:\csharp\axiom_svn\trunk_orig\trunk\Projects\Axiom\Engine\Core\SceneManager.cs:line 6002 at Axiom.Core.SceneManager.RenderVisibleObjects() in F:\csharp\axiom_svn\trunk_orig\trunk\Projects\Axiom\Engine\Core\SceneManager.cs:line 6090 at Axiom.Core.SceneManager.RenderScene(Camera camera, Viewport viewport, Boolean showOverlays) in F:\csharp\axiom_svn\trunk_orig\trunk\Projects\Axiom\Engine\Core\SceneManager.cs:line 4583 at Axiom.Core.Camera.RenderScene(Viewport viewport, Boolean showOverlays) in F:\csharp\axiom_svn\trunk_orig\trunk\Projects\Axiom\Engine\Core\Camera.cs:line 1648 at Axiom.Core.Viewport.Update() in F:\csharp\axiom_svn\trunk_orig\trunk\Projects\Axiom\Engine\Core\Viewport.cs:line 692 at Axiom.Graphics.RenderTarget.Update() in F:\csharp\axiom_svn\trunk_orig\trunk\Projects\Axiom\Engine\Graphics\RenderTarget.cs:line 876 at Axiom.Graphics.RenderWindow.Update(Boolean swapBuffers) in F:\csharp\axiom_svn\trunk_orig\trunk\Projects\Axiom\Engine\Graphics\RenderWindow.cs:line 293 at Axiom.RenderSystems.DirectX9.D3DRenderWindow.Update(Boolean swapBuffers) in F:\csharp\axiom_svn\trunk_orig\trunk\Projects\Axiom\RenderSystems\DirectX9\D3DRenderWindow.cs:line 1148 at Axiom.Graphics.RenderWindow.Update() in F:\csharp\axiom_svn\trunk_orig\trunk\Projects\Axiom\Engine\Graphics\RenderWindow.cs:line 269 at Axiom.Graphics.RenderSystem.UpdateAllRenderTargets() in F:\csharp\axiom_svn\trunk_orig\trunk\Projects\Axiom\Engine\Graphics\RenderSystem.cs:line 750 at Axiom.Core.Root.UpdateAllRenderTargets() in F:\csharp\axiom_svn\trunk_orig\trunk\Projects\Axiom\Engine\Core\Root.cs:line 1003 at Axiom.Core.Root.RenderOneFrame() in F:\csharp\axiom_svn\trunk_orig\trunk\Projects\Axiom\Engine\Core\Root.cs:line 927 at Axiom.Core.Root.StartRendering() in F:\csharp\axiom_svn\trunk_orig\trunk\Projects\Axiom\Engine\Core\Root.cs:line 957 at Axiom.Demos.TechDemo.Start() in F:\csharp\axiom_svn\trunk_orig\trunk\Projects\AxiomDemos\Source\Demos\TechDemo.cs:line 392
|
|
|
|
 |
|
andris11
|
Post subject: Re: Removing and creating entity Posted: Fri Nov 06, 2009 5:40 pm |
Joined: Wed Mar 22, 2006 8:06 pm Posts: 622
|
SubEntity.Lights Code: public LightList Lights { get { // get the parent entitie's parent node Node node = parent.ParentNode;
Debug.Assert( node != null );
643 return parent.ParentNode.Lights; } }
then the MovableObject.ParentNode in the SubEntity's parent object becomes null. At a glance it is setup correctly in SceneNode.AttachObject() -> MovableObject.NotifyAttached() and any NotifyAttached() overrides don't break it. No idea how it becomes null, needs some debugging maybe, can't help atm, if you don't solve, don't forget to file a bug ticket with a (possibly simplest) failing TechDemo test, that will help
|
|
|
|
 |
|
migel
|
Post subject: Re: Removing and creating entity Posted: Sat Nov 07, 2009 1:06 pm |
| Veteran |
 |
Joined: Fri Apr 17, 2009 7:38 am Posts: 65 Location: Finland
|
|
It seems that sceneNode.DetachObject is the problem. When replacing it with sceneNode.DetachAllObjects(); then it works. But Ill make a ticket.
|
|
|
|
 |
|
andris11
|
Post subject: Re: Removing and creating entity Posted: Sat Nov 07, 2009 2:11 pm |
Joined: Wed Mar 22, 2006 8:06 pm Posts: 622
|
|
To me it seems that DetachAllObjects() has a bit "hacky" impl, because it doesn't notify the attached objects of parent change to null, comparing with OGRE confirms that. DetachObject() should be fine, it makes the MovableObject.Parent null, but that's correct.
I can confirm the issue, going to debug a bit, first clue: just noted that the ogreHead is not attached to RootSceneNode at all in the CameraTrack demo
|
|
|
|
 |
|
andris11
|
Post subject: Re: Removing and creating entity Posted: Sat Nov 07, 2009 2:27 pm |
Joined: Wed Mar 22, 2006 8:06 pm Posts: 622
|
The problem is in SceneNode.AttachObject() ln 385 Code: objectList.Add( obj ); is to be replaced with Code: objectList.Add( obj.Name, obj ); There might be more places of that sort, I'll look into it a bit.
|
|
|
|
 |
|
andris11
|
Post subject: Re: Removing and creating entity Posted: Sat Nov 07, 2009 3:12 pm |
Joined: Wed Mar 22, 2006 8:06 pm Posts: 622
|
I added a patch to the ticket. The above correction is not required if you use the patch.
|
|
|
|
 |
|
migel
|
Post subject: Re: Removing and creating entity Posted: Sun Nov 08, 2009 2:56 am |
| Veteran |
 |
Joined: Fri Apr 17, 2009 7:38 am Posts: 65 Location: Finland
|
|
That was fast. Patch works great. But using DetachAllObjects() until patch reaches to trunk.
|
|
|
|
 |
|
|