christian.wolf2 Posted June 15, 2017 Posted June 15, 2017 Hi, I don't know if this bug is related to version 2.5 or the previous one, but the engine crashed when I try to get the height of my ObjectTerrainPtr. ObjectTerrainPtr objTerrain = ObjectTerrain::cast(newObject); // try to cast NodePtr to ObjectTerrainPtr if (objTerrain.get() != NULL) { Log::message("getStep: %f\n", objTerrain->getStep()); //Step is successfully printed Log::message("getHeight: %f\n", objTerrain->getHeight(10, 10)); //Crash on program } I tried either float or integer variables in getting the height, but I got the same result. I tried to reproduce those behavior in UnigineScript (to exclude error in terrain data), but therefor I got the correct height.
paralyzah Posted June 20, 2017 Posted June 20, 2017 Hello ChristianI created a new c ++ project in an SDK browserIn the editor, I added the node ObjectTerrain_0 (you can also import the height and albedo data into it) via Create - Object - ObjectTerrainIn the AppWorldLogic.cpp file, I added the following code: int AppWorldLogic::init() { // Write here code to be called on world initialization: initialize resources for your world scene during the world start. NodePtr newObject = Editor::get()->getNodeByName("ObjectTerrain_0"); ObjectTerrainPtr objTerrain = ObjectTerrain::cast(newObject); if (objTerrain.get() != NULL) { Log::message("getStep: %f\n", objTerrain->getStep()); Log::message("getHeight: %f\n", objTerrain->getHeight(100, 100)); } return 1; } The project was compiled and run without errorsIn the console, the following messages (if you import height and albedo data):getStep: 1.000000getHeight: 9.803923Can you elaborate on how you use get-> height in your project? Thanks
christian.wolf2 Posted June 20, 2017 Author Posted June 20, 2017 Hi, thanks for the reply. I got it worked on my site. I relinked all the files in VS and the error crash disappeared. Maybe I had some old libraries used. Sorry for the inconvenience caused.
Recommended Posts