AbsolutePosition in ITerrainSceneNode not updated

You discovered a bug in the engine, and you are sure that it is not a problem of your code? Just post it in here. Please read the bug posting guidelines first.
Post Reply
josemrsantos
Posts: 8
Joined: Wed Dec 19, 2012 3:06 pm

AbsolutePosition in ITerrainSceneNode not updated

Post by josemrsantos »

As posted here: http://irrlicht.sourceforge.net/forum/v ... 4&p=276788
I think there is a bug on ITerrainSceneNode, where AbsolutePosition is not returning the correct value, if the terrain is moved, even if updateAbsolutePosition is called.

Using Irrlicht 1.8 .

Code:

Code: Select all

 
#include <irrlicht.h>
#include "driverChoice.h"
#include <iostream>
#include <string>
#include <sstream>
 
using namespace irr;
using namespace std;
 
#ifdef _MSC_VER
#pragma comment(lib, "Irrlicht.lib")
#endif
 
int main()
{
 
  video::E_DRIVER_TYPE driverType=driverChoiceConsole();
  if (driverType==video::EDT_COUNT)
    return 1;
 
  irr::SIrrlichtCreationParameters params;
  params.DriverType=driverType;
  params.WindowSize=core::dimension2d<u32>(800, 600);
  params.Fullscreen= false;
  IrrlichtDevice* device = createDeviceEx(params);
  if (device == 0)
    return 1;
  video::IVideoDriver* driver = device->getVideoDriver();
  scene::ISceneManager* smgr = device->getSceneManager();
 
  scene::IMeshSceneNode* pinet1 = smgr->addMeshSceneNode(smgr->getMesh("./f_pinetree1/b3d__pinet1.b3d"));
  cout << "------------------ TEST IMeshSceneNode before setPosition   ------------\n";
  cout << "(";
  cout << pinet1->getAbsolutePosition().X;
  cout << ":";
  cout << pinet1->getAbsolutePosition().Z;
  cout << ")=(";
  cout << pinet1->getPosition().X;
  cout << ":";
  cout << pinet1->getPosition().Z;
  cout << ")\n";
  pinet1->setPosition(core::vector3df(11,100,11));
  cout << "------------------ TEST IMeshSceneNode after setPosition, before updateAbsolutePosition   ------------\n";
  cout << "(";
  cout << pinet1->getAbsolutePosition().X;
  cout << ":";
  cout << pinet1->getAbsolutePosition().Z;
  cout << ")=(";
  cout << pinet1->getPosition().X;
  cout << ":";
  cout << pinet1->getPosition().Z;
  cout << ")\n";
  pinet1->updateAbsolutePosition();
  cout << "------------------ TEST IMeshSceneNode after updateAbsolutePosition   ------------\n";
  cout << "(";
  cout << pinet1->getAbsolutePosition().X;
  cout << ":";
  cout << pinet1->getAbsolutePosition().Z;
  cout << ")=(";
  cout << pinet1->getPosition().X;
  cout << ":";
  cout << pinet1->getPosition().Z;
  cout << ")\n\n";
 
  scene::ITerrainSceneNode* terrain3 = smgr->addTerrainSceneNode("terrain.bmp");
  cout << "------------------ TEST TerrainSceneNode before setPosition   ------------\n";
  cout << "(";
  cout << terrain3->getAbsolutePosition().X;
  cout << ":";
  cout << terrain3->getAbsolutePosition().Z;
  cout << ")=(";
  cout << terrain3->getPosition().X;
  cout << ":";
  cout << terrain3->getPosition().Z;
  cout << ")\n";
  terrain3->setPosition(core::vector3df(11,100,11));
  cout << "------------------ TEST TerrainSceneNode after setPosition, before updateAbsolutePosition   ------------\n";
  cout << "(";
  cout << terrain3->getAbsolutePosition().X;
  cout << ":";
  cout << terrain3->getAbsolutePosition().Z;
  cout << ")=(";
  cout << terrain3->getPosition().X;
  cout << ":";
  cout << terrain3->getPosition().Z;
  cout << ")\n";
  terrain3->updateAbsolutePosition();
  cout << "------------------ TEST TerrainSceneNode after updateAbsolutePosition   ------------\n";
  cout << "(";
  cout << terrain3->getAbsolutePosition().X;
  cout << ":";
  cout << terrain3->getAbsolutePosition().Z;
  cout << ")=(";
  cout << terrain3->getPosition().X;
  cout << ":";
  cout << terrain3->getPosition().Z;
  cout << ")\t\n\n";
  
  exit(0);
}
 
Code output, where (absolutePosition.X:absolutePosition.Z)=(position.X:position.Z):

Code: Select all

 
------------------ TEST IMeshSceneNode before setPosition   ------------
(0:0)=(0:0)
------------------ TEST IMeshSceneNode after setPosition, before updateAbsolutePosition   ------------
(0:0)=(11:11)
------------------ TEST IMeshSceneNode after updateAbsolutePosition   ------------
(11:11)=(11:11)
 
Generated terrain data (129x129) in 0.0440 seconds
------------------ TEST TerrainSceneNode before setPosition   ------------
(0:0)=(0:0)
------------------ TEST TerrainSceneNode after setPosition, before updateAbsolutePosition   ------------
(0:0)=(11:11)
------------------ TEST TerrainSceneNode after updateAbsolutePosition   ------------
(0:0)=(11:11)
 
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: AbsolutePosition in ITerrainSceneNode not updated

Post by CuteAlien »

CTerrainSceneNode does overwrite setPosition for some reason and not change the node-position. But don't know why it's doing that on a quick first look. Anyone got an idea? Maybe we should overwrite getAbsolutePosition and getAbsoluteTransformation additionally.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Re: AbsolutePosition in ITerrainSceneNode not updated

Post by hybrid »

The terrain scene node does all this position handling on its own. Not sure why really, but all the internal handling depends on it. Changing all this back to the usual way would probably be the better way, but having a quick fix which makes most of its interaction correct would also help.
Post Reply