[Bf-committers] [Bf-blender-cvs] SVN commit: /data/svn/bf-blender [32204] trunk/blender/source/gameengine/ Ketsji/KX_Dome.cpp: use constant rather then sqrt(2.0)

Dalai Felinto dfelinto at gmail.com
Thu Sep 30 14:16:35 CEST 2010


small note , not all unrecognized characters were º (specially not the ones
in the credit).
I can look at that another time. now in a bug rush here (tonight big bge
dome event and I still have to make bpayer wrk there :/
2010/9/30 Campbell Barton <ideasman42 at gmail.com>

> Revision: 32204
>
> http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=32204
> Author:   campbellbarton
> Date:     2010-09-30 09:06:00 +0200 (Thu, 30 Sep 2010)
>
> Log Message:
> -----------
> use constant rather then sqrt(2.0)
>
> Modified Paths:
> --------------
>    trunk/blender/source/gameengine/Ketsji/KX_Dome.cpp
>
> Modified: trunk/blender/source/gameengine/Ketsji/KX_Dome.cpp
> ===================================================================
> --- trunk/blender/source/gameengine/Ketsji/KX_Dome.cpp  2010-09-30 06:58:19
> UTC (rev 32203)
> +++ trunk/blender/source/gameengine/Ketsji/KX_Dome.cpp  2010-09-30 07:06:00
> UTC (rev 32204)
> @@ -18,7 +18,7 @@
>  Contributor(s): Dalai Felinto
>
>  This code is originally inspired on some of the ideas and codes from Paul
> Bourke.
> -Developed as part of a Research and Development project for SAT - La
> Soci�t� des arts technologiques.
> +Developed as part of a Research and Development project for SAT - La
> Socidegtdeg des arts technologiques.
>
>  -----------------------------------------------------------------------------
>  */
>
> @@ -556,26 +556,25 @@
>  - transform it onto an equidistant spherical projection techniques to
> transform the sphere onto a dome image
>  */
>        int i,j;
> -       float sqrt_2 = sqrt(2.0);
>        float uv_ratio = (float)(m_buffersize-1) / m_imagesize;
>
>        m_radangle = m_angle * M_PI/180.0;//calculates the radians angle,
> used for flattening
>
> -       //creating faces for the env mapcube 180� Dome
> +       //creating faces for the env mapcube 180deg Dome
>        // Top Face - just a triangle
> -       cubetop[0].verts[0][0] = -sqrt_2 / 2.0;
> +       cubetop[0].verts[0][0] = -M_SQRT2 / 2.0;
>        cubetop[0].verts[0][1] = 0.0;
>        cubetop[0].verts[0][2] = 0.5;
>        cubetop[0].u[0] = 0.0;
>        cubetop[0].v[0] = uv_ratio;
>
>        cubetop[0].verts[1][0] = 0.0;
> -       cubetop[0].verts[1][1] = sqrt_2 / 2.0;
> +       cubetop[0].verts[1][1] = M_SQRT2 / 2.0;
>        cubetop[0].verts[1][2] = 0.5;
>        cubetop[0].u[1] = 0.0;
>        cubetop[0].v[1] = 0.0;
>
> -       cubetop[0].verts[2][0] = sqrt_2 / 2.0;
> +       cubetop[0].verts[2][0] = M_SQRT2 / 2.0;
>        cubetop[0].verts[2][1] = 0.0;
>        cubetop[0].verts[2][2] = 0.5;
>        cubetop[0].u[2] = uv_ratio;
> @@ -584,20 +583,20 @@
>        nfacestop = 1;
>
>        /* Bottom face - just a triangle */
> -       cubebottom[0].verts[0][0] = -sqrt_2 / 2.0;
> +       cubebottom[0].verts[0][0] = -M_SQRT2 / 2.0;
>        cubebottom[0].verts[0][1] = 0.0;
>        cubebottom[0].verts[0][2] = -0.5;
>        cubebottom[0].u[0] = uv_ratio;
>        cubebottom[0].v[0] = 0.0;
>
> -       cubebottom[0].verts[1][0] = sqrt_2 / 2.0;
> +       cubebottom[0].verts[1][0] = M_SQRT2 / 2.0;
>        cubebottom[0].verts[1][1] = 0;
>        cubebottom[0].verts[1][2] = -0.5;
>        cubebottom[0].u[1] = 0.0;
>        cubebottom[0].v[1] = uv_ratio;
>
>        cubebottom[0].verts[2][0] = 0.0;
> -       cubebottom[0].verts[2][1] = sqrt_2 / 2.0;
> +       cubebottom[0].verts[2][1] = M_SQRT2 / 2.0;
>        cubebottom[0].verts[2][2] = -0.5;
>        cubebottom[0].u[2] = 0.0;
>        cubebottom[0].v[2] = 0.0;
> @@ -606,39 +605,39 @@
>
>        /* Left face - two triangles */
>
> -       cubeleft[0].verts[0][0] = -sqrt_2 / 2.0;
> +       cubeleft[0].verts[0][0] = -M_SQRT2 / 2.0;
>        cubeleft[0].verts[0][1] = .0;
>        cubeleft[0].verts[0][2] = -0.5;
>        cubeleft[0].u[0] = 0.0;
>        cubeleft[0].v[0] = 0.0;
>
>        cubeleft[0].verts[1][0] = 0.0;
> -       cubeleft[0].verts[1][1] = sqrt_2 / 2.0;
> +       cubeleft[0].verts[1][1] = M_SQRT2 / 2.0;
>        cubeleft[0].verts[1][2] = -0.5;
>        cubeleft[0].u[1] = uv_ratio;
>        cubeleft[0].v[1] = 0.0;
>
> -       cubeleft[0].verts[2][0] = -sqrt_2 / 2.0;
> +       cubeleft[0].verts[2][0] = -M_SQRT2 / 2.0;
>        cubeleft[0].verts[2][1] = 0.0;
>        cubeleft[0].verts[2][2] = 0.5;
>        cubeleft[0].u[2] = 0.0;
>        cubeleft[0].v[2] = uv_ratio;
>
>        //second triangle
> -       cubeleft[1].verts[0][0] = -sqrt_2 / 2.0;
> +       cubeleft[1].verts[0][0] = -M_SQRT2 / 2.0;
>        cubeleft[1].verts[0][1] = 0.0;
>        cubeleft[1].verts[0][2] = 0.5;
>        cubeleft[1].u[0] = 0.0;
>        cubeleft[1].v[0] = uv_ratio;
>
>        cubeleft[1].verts[1][0] = 0.0;
> -       cubeleft[1].verts[1][1] = sqrt_2 / 2.0;
> +       cubeleft[1].verts[1][1] = M_SQRT2 / 2.0;
>        cubeleft[1].verts[1][2] = -0.5;
>        cubeleft[1].u[1] = uv_ratio;
>        cubeleft[1].v[1] = 0.0;
>
>        cubeleft[1].verts[2][0] = 0.0;
> -       cubeleft[1].verts[2][1] = sqrt_2 / 2.0;
> +       cubeleft[1].verts[2][1] = M_SQRT2 / 2.0;
>        cubeleft[1].verts[2][2] = 0.5;
>        cubeleft[1].u[2] = uv_ratio;
>        cubeleft[1].v[2] = uv_ratio;
> @@ -647,18 +646,18 @@
>
>        /* Right face - two triangles */
>        cuberight[0].verts[0][0] = 0.0;
> -       cuberight[0].verts[0][1] = sqrt_2 / 2.0;
> +       cuberight[0].verts[0][1] = M_SQRT2 / 2.0;
>        cuberight[0].verts[0][2] = -0.5;
>        cuberight[0].u[0] = 0.0;
>        cuberight[0].v[0] = 0.0;
>
> -       cuberight[0].verts[1][0] = sqrt_2 / 2.0;
> +       cuberight[0].verts[1][0] = M_SQRT2 / 2.0;
>        cuberight[0].verts[1][1] = 0.0;
>        cuberight[0].verts[1][2] = -0.5;
>        cuberight[0].u[1] = uv_ratio;
>        cuberight[0].v[1] = 0.0;
>
> -       cuberight[0].verts[2][0] = sqrt_2 / 2.0;
> +       cuberight[0].verts[2][0] = M_SQRT2 / 2.0;
>        cuberight[0].verts[2][1] = 0.0;
>        cuberight[0].verts[2][2] = 0.5;
>        cuberight[0].u[2] = uv_ratio;
> @@ -666,19 +665,19 @@
>
>        //second triangle
>        cuberight[1].verts[0][0] = 0.0;
> -       cuberight[1].verts[0][1] = sqrt_2 / 2.0;
> +       cuberight[1].verts[0][1] = M_SQRT2 / 2.0;
>        cuberight[1].verts[0][2] = -0.5;
>        cuberight[1].u[0] = 0.0;
>        cuberight[1].v[0] = 0.0;
>
> -       cuberight[1].verts[1][0] = sqrt_2 / 2.0;
> +       cuberight[1].verts[1][0] = M_SQRT2 / 2.0;
>        cuberight[1].verts[1][1] = 0.0;
>        cuberight[1].verts[1][2] = 0.5;
>        cuberight[1].u[1] = uv_ratio;
>        cuberight[1].v[1] = uv_ratio;
>
>        cuberight[1].verts[2][0] = 0.0;
> -       cuberight[1].verts[2][1] = sqrt_2 / 2.0;
> +       cuberight[1].verts[2][1] = M_SQRT2 / 2.0;
>        cuberight[1].verts[2][2] = 0.5;
>        cuberight[1].u[2] = 0.0;
>        cuberight[1].v[2] = uv_ratio;
> @@ -746,7 +745,7 @@
>        m_radangle = m_angle * M_PI/180.0;//calculates the radians angle,
> used for flattening
>  /*
>  verts_height is the exactly needed height of the cube faces (not always
> 1.0).
> -When we want some horizontal information (e.g. for horizontal 220� domes)
> we don't need to create and tesselate the whole cube.
> +When we want some horizontal information (e.g. for horizontal 220deg
> domes) we don't need to create and tesselate the whole cube.
>  Therefore the lateral cube faces could be small, and the tesselate mesh
> would be completely used.
>  (if we always worked with verts_height = 1.0, we would be discarding a lot
> of the calculated and tesselated geometry).
>
> @@ -758,12 +757,12 @@
>  Once we take the tangent of that angle, you have the verts coordinate
> corresponding to the verts on the side faces.
>  Then we need to multiply it by sqrt(2.0) to get the coordinate of the
> verts on the diagonal of the original cube.
>  */
> -       verts_height = tan((rad_ang/2) - (MT_PI/2))*sqrt(2.0);
> +       verts_height = tan((rad_ang/2) - (MT_PI/2))*M_SQRT2;
>
>        uv_height = uv_ratio * ((verts_height/2) + 0.5);
>        uv_base = uv_ratio * (1.0 - ((verts_height/2) + 0.5));
>
> -       //creating faces for the env mapcube 180� Dome
> +       //creating faces for the env mapcube 180deg Dome
>        // Front Face - 2 triangles
>        cubefront[0].verts[0][0] =-1.0;
>        cubefront[0].verts[0][1] = 1.0;
> @@ -1021,42 +1020,41 @@
>  */
>        int i,j;
>
> -       float sqrt_2 = sqrt(2.0);
>        float uv_ratio = (float)(m_buffersize-1) / m_imagesize;
>
>        /* Top face - two triangles */
> -       cubetop[0].verts[0][0] = -sqrt_2;
> +       cubetop[0].verts[0][0] = -M_SQRT2;
>        cubetop[0].verts[0][1] = 0.0;
>        cubetop[0].verts[0][2] = 1.0;
>        cubetop[0].u[0] = 0.0;
>        cubetop[0].v[0] = uv_ratio;
>
>        cubetop[0].verts[1][0] = 0.0;
> -       cubetop[0].verts[1][1] = sqrt_2;
> +       cubetop[0].verts[1][1] = M_SQRT2;
>        cubetop[0].verts[1][2] = 1.0;
>        cubetop[0].u[1] = 0.0;
>        cubetop[0].v[1] = 0.0;
>
>        //second triangle
> -       cubetop[0].verts[2][0] = sqrt_2;
> +       cubetop[0].verts[2][0] = M_SQRT2;
>        cubetop[0].verts[2][1] = 0.0;
>        cubetop[0].verts[2][2] = 1.0;
>        cubetop[0].u[2] = uv_ratio;
>        cubetop[0].v[2] = 0.0;
>
> -       cubetop[1].verts[0][0] = sqrt_2;
> +       cubetop[1].verts[0][0] = M_SQRT2;
>        cubetop[1].verts[0][1] = 0.0;
>        cubetop[1].verts[0][2] = 1.0;
>        cubetop[1].u[0] = uv_ratio;
>        cubetop[1].v[0] = 0.0;
>
>        cubetop[1].verts[1][0] = 0.0;
> -       cubetop[1].verts[1][1] = -sqrt_2;
> +       cubetop[1].verts[1][1] = -M_SQRT2;
>        cubetop[1].verts[1][2] = 1.0;
>        cubetop[1].u[1] = uv_ratio;
>        cubetop[1].v[1] = uv_ratio;
>
> -       cubetop[1].verts[2][0] = -sqrt_2;
> +       cubetop[1].verts[2][0] = -M_SQRT2;
>        cubetop[1].verts[2][1] = 0.0;
>        cubetop[1].verts[2][2] = 1.0;
>        cubetop[1].u[2] = 0.0;
> @@ -1065,79 +1063,79 @@
>        nfacestop = 2;
>
>        /* Bottom face - two triangles */
> -       cubebottom[0].verts[0][0] = -sqrt_2;
> +       cubebottom[0].verts[0][0] = -M_SQRT2;
>        cubebottom[0].verts[0][1] = 0.0;
>        cubebottom[0].verts[0][2] = -1.0;
>        cubebottom[0].u[0] = uv_ratio;
>        cubebottom[0].v[0] = 0.0;
>
> -       cubebottom[0].verts[1][0] = sqrt_2;
> +       cubebottom[0].verts[1][0] = M_SQRT2;
>        cubebottom[0].verts[1][1] = 0.0;
>        cubebottom[0].verts[1][2] = -1.0;
>        cubebottom[0].u[1] = 0.0;
>        cubebottom[0].v[1] = uv_ratio;
>
>        cubebottom[0].verts[2][0] = 0.0;
> -       cubebottom[0].verts[2][1] = sqrt_2;
> +       cubebottom[0].verts[2][1] = M_SQRT2;
>        cubebottom[0].verts[2][2] = -1.0;
>        cubebottom[0].u[2] = 0.0;
>        cubebottom[0].v[2] = 0.0;
>
>        //second triangle
> -       cubebottom[1].verts[0][0] = sqrt_2;
> +       cubebottom[1].verts[0][0] = M_SQRT2;
>        cubebottom[1].verts[0][1] = 0.0;
>        cubebottom[1].verts[0][2] = -1.0;
>        cubebottom[1].u[0] = 0.0;
>        cubebottom[1].v[0] = uv_ratio;
>
> -       cubebottom[1].verts[1][0] = -sqrt_2;
> +       cubebottom[1].verts[1][0] = -M_SQRT2;
>        cubebottom[1].verts[1][1] = 0.0;
>        cubebottom[1].verts[1][2] = -1.0;
>        cubebottom[1].u[1] = uv_ratio;
>        cubebottom[1].v[1] = 0.0;
>
>        cubebottom[1].verts[2][0] = 0.0;
> -       cubebottom[1].verts[2][1] = -sqrt_2;
> +       cubebottom[1].verts[2][1] = -M_SQRT2;
>        cubebottom[1].verts[2][2] = -1.0;
>        cubebottom[1].u[2] = uv_ratio;
>        cubebottom[1].v[2] = uv_ratio;
>
>        nfacesbottom = 2;
>
> -       /* Left Back (135�) face - two triangles */
> +       /* Left Back (135deg) face - two triangles */
>
>        cubeleftback[0].verts[0][0] = 0;
> -       cubeleftback[0].verts[0][1] = -sqrt_2;
> +       cubeleftback[0].verts[0][1] = -M_SQRT2;
>        cubeleftback[0].verts[0][2] = -1.0;
>        cubeleftback[0].u[0] = 0;
>        cubeleftback[0].v[0] = 0;
>
> -       cubeleftback[0].verts[1][0] = -sqrt_2;
> +       cubeleftback[0].verts[1][0] = -M_SQRT2;
>        cubeleftback[0].verts[1][1] = 0;
>        cubeleftback[0].verts[1][2] = -1.0;
>        cubeleftback[0].u[1] = uv_ratio;
>        cubeleftback[0].v[1] = 0;
>
>        cubeleftback[0].verts[2][0] = 0;
> -       cubeleftback[0].verts[2][1] = -sqrt_2;
> +       cubeleftback[0].verts[2][1] = -M_SQRT2;
>        cubeleftback[0].verts[2][2] = 1.0;
>        cubeleftback[0].u[2] = 0;
>        cubeleftback[0].v[2] = uv_ratio;
>
>        //second triangle
>        cubeleftback[1].verts[0][0] = 0;
> -       cubeleftback[1].verts[0][1] = -sqrt_2;
> +       cubeleftback[1].verts[0][1] = -M_SQRT2;
>        cubeleftback[1].verts[0][2] = 1.0;
>        cubeleftback[1].u[0] = 0;
>        cubeleftback[1].v[0] = uv_ratio;
>
> -       cubeleftback[1].verts[1][0] = -sqrt_2;
> +       cubeleftback[1].verts[1][0] = -M_SQRT2;
>        cubeleftback[1].verts[1][1] = 0;
>        cubeleftback[1].verts[1][2] = -1.0;
>        cubeleftback[1].u[1] = uv_ratio;
>        cubeleftback[1].v[1] = 0;
>
> -       cubeleftback[1].verts[2][0] = -sqrt_2;
>
> @@ Diff output truncated at 10240 characters. @@
>
> _______________________________________________
> Bf-blender-cvs mailing list
> Bf-blender-cvs at blender.org
> http://lists.blender.org/mailman/listinfo/bf-blender-cvs
>


More information about the Bf-committers mailing list