Horde3D http://horde3d.org/forums/ |
|
[solved] Might be a bug for terrain block info building? http://horde3d.org/forums/viewtopic.php?f=3&t=284 |
Page 1 of 1 |
Author: | doublue [ 16.04.2008, 05:13 ] |
Post subject: | [solved] Might be a bug for terrain block info building? |
Sources excerpted from terrain.cpp: Code: Vec3f corner0( minU + u * stepU, 0, minV + v * stepV); Vec3f corner1( minU + u * stepU, 0, minV + (v + 1) * stepV); Vec3f corner2( minU + (u + 1) * stepU, 0, minV + v * stepV); Vec3f corner3( minU + (u + 1) * stepU, 0, minV + (v + 1) * stepV); ...... Plane tri0( corner0, corner1, corner2 ); Plane tri1( corner1, corner2, corner3 ); for( float vv = 0; vv <= stepV; vv += pixelStep ) { for( float uu = 0; uu <= stepU; uu += pixelStep ) { Plane &curTri = uu <= vv ? tri0 : tri1; Assume (0,0) to be the left-top corner (or any), as follows: V0 -------V2 | Tri0 / | | / | | / Tri1| V1--------V3 IMHO for statement curTri = tri0 iff uu <= vv to be true, the tri0 should be (V0, V1, V3) and tri1 (V0, V2, V3). Otherwise different rule for deciding curTri needed. |
Author: | Volker [ 16.04.2008, 11:39 ] |
Post subject: | Re: Might be a bug for terrain block info building? |
I've not checked it in detail, but it seems to me that it does not make any difference. But I've found another problem in the terrain rendering. I can't remember why we had the following statement in the drawTerrainBlock method in terrain.cpp Code: float newU = (s * scale + minU) * (terrain->_hmapSize - 1) + 0.4f; float newV = (t * scale + minV) * (terrain->_hmapSize - 1) + 0.4f; With this code, the rendering seems not to match with the blockInfo used for the frustum culling (You can check this setting the camera position to x = 278.97134, y = 62.080597, and z = 425.14410 and by adding the following line to drawTerrainBlock method after the glDrawElements call) Code: Modules::renderer().drawDebugAABB(bb.getMinCoords(), bb.getMaxCoords(), true); If you change it to... Code: float newU = (s * scale + minU) * (terrain->_hmapSize - 1) + 0.5f; float newV = (t * scale + minV) * (terrain->_hmapSize - 1) + 0.5f; ...everything seems to be fine in the terrain example. Maybe someone else can check this. During a quick check it solves the still existing frustum culling problems also mentioned in this thread Edit: To use the drawDebugAABB method correctly you should insert the following line after the if( saveStates ) statement: Code: glUseProgram( shader );
|
Page 1 of 1 | All times are UTC + 1 hour |
Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |