Akshay.Patil Posted February 16, 2017 Share Posted February 16, 2017 Hello , We are trying calculate the intersection point of mouse with Terrain. We are using the api ObjectTerrain::getIntersection() from unigine script. And I observed issue that for the same set of input I was getting no intersection at first few clicks But after few mouse clicks at the same point i got the intersection. Code we are using : vec3 startPos,endPos; Unigine::getPlayerMouseDirection(startPos,endPos) ObjectIntersection intersection = new ObjectIntersection(); vec3 p0 = terrainObject.getIWorldTransform() * startPos; vec3 p1 = terrainObject.getIWorldTransform() * endPos; if( terrainObject.getIntersection(p0,p1, intersection, 0 ) == 1 ) { // we have intersectionPoint // } I debugged the code and found that int TerrainSurface::getIntersection(const vec3 &point_0,const vec3 &point_1,vec3 *ret_point,vec3 *ret_normal,vec4 *ret_texcoord,int holes) Calls createPatches() and then uses the patches for calculating intersection points. if the patches were created during the call createPatches() if they were not present TerrainSurface state is set to dirty (As patches are still not valid , no valid bounding boxes i think ) I hope it is not right to do intersection with newly created patches. So i have modified the code as below which fixed the issue int TerrainSurface::getIntersection(const vec3 &point_0,const vec3 &point_1,vec3 *ret_point,vec3 *ret_normal,vec4 *ret_texcoord,int holes) { loadHeights(1); if (patch_root == NULL) { createPatches(); update(); } Can you please confirm that the problem we are facing is a bug in TerrainSurface::getIntersection ? is the fix right ? Optimised ? or Do we need to change our application code ? Link to comment
silent Posted February 16, 2017 Share Posted February 16, 2017 Akshay, Thank you for the patch. Our devs will take a look into in more closely and merge to fix this behavior in future versions. How to submit a good bug report --- FTP server for test scenes and user uploads: ftp://files.unigine.com user: upload password: 6xYkd6vLYWjpW6SN Link to comment
silent Posted February 27, 2017 Share Posted February 27, 2017 Will be fixed in 2.4.1. How to submit a good bug report --- FTP server for test scenes and user uploads: ftp://files.unigine.com user: upload password: 6xYkd6vLYWjpW6SN Link to comment
Recommended Posts