Access Violation on clearScene(); with autotracking camera.

A place for users of OGRE to discuss ideas and experiences of utilitising OGRE in their games / demos / applications.
User avatar
Goosey
Halfling
Posts: 88
Joined: Wed Sep 29, 2004 3:33 am
Location: Ohio, USA

Access Violation on clearScene(); with autotracking camera.

Post by Goosey »

I ran into a odd little thing today. I was playing with setAutoTracking on a camera. I found that when I called clearScene() from the scenemanager I was getting an unhandled exception (an access violation, the debugger revealed) which was apparently happening in Camera::_autoTrack()

I found if I called setAutoTracking(false); on the camera right before clearScene() then I had no problems at all, so the issue certainly isn't critical, but it did seem a little odd.

Is this a bug or by design? Either way just thought I would bring it up.
I <3 the OGRE Wiki, and SO SHOULD YOU! :)
User avatar
:wumpus:
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 3067
Joined: Tue Feb 10, 2004 12:53 pm
Location: The Netherlands
x 1

Post by :wumpus: »

Could you post the exact line it happens?
User avatar
sinbad
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 19269
Joined: Sun Oct 06, 2002 11:19 pm
Location: Guernsey, Channel Islands
x 66

Post by sinbad »

The auto tracking scene node list is emptied on clearScene() so I don't see why this should occur.
User avatar
Goosey
Halfling
Posts: 88
Joined: Wed Sep 29, 2004 3:33 am
Location: Ohio, USA

Post by Goosey »

:wumpus: wrote:Could you post the exact line it happens?

Code: Select all

    
void Camera::_autoTrack(void)
    {
        // NB assumes that all scene nodes have been updated
        if (mAutoTrackTarget)
        {
            lookAt(mAutoTrackTarget->_getDerivedPosition() + mAutoTrackOffset);   //<-- RIGHT HERE
        }
    }
This only happens when the Camera was using the auto tracking. A node autotracking another node, and no problems.

EDIT: I should mention this is in a state-management system.. clearScene() is getting called when the state exits (back to main menu), but the camera remains since the mRoot is not destroyed till the main menu exits.
I <3 the OGRE Wiki, and SO SHOULD YOU! :)
User avatar
jacmoe
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 20570
Joined: Thu Jan 22, 2004 10:13 am
Location: Denmark
x 179

Post by jacmoe »

Well, shouldn't you recreate your camera when switching scenes?
I read it here :?:
/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.
User avatar
sinbad
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 19269
Joined: Sun Oct 06, 2002 11:19 pm
Location: Guernsey, Channel Islands
x 66

Post by sinbad »

You will have to tell the camera to stop tracking if you destroy the scene; nodes don't know when a camera is tracking them so can't tell it to stop. It is possible to sort it out on clearScene but not for removal of a specific node so the principle should apply globally. Sorry, for some reason I thought you meant node-node tracking.