nel-all
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Nel] Minor fixes


From: Loic Dachary
Subject: [Nel] Minor fixes
Date: Wed, 14 Aug 2002 11:10:39 +0200

        Hi,

        Here is a small patch that gets rid of warnings related to the
address of temporary variables being passed as argument to a function
(IDriver::setConstant). I merely changed the prototype to be a
reference instead of a pointer. This change is included in the Debian
packages I generated and tested earlier today. Please let me know if
the change is acceptable to you. 

        I also included a fix to the following problems:

        . char used instead of uint8 in expressions such as (c >= 128)
        . nldebug called with path instead of path.c_str() 

        Cheers, 

--- nel.orig/src/3d/driver.h
+++ nel/src/3d/driver.h
@@ -729,8 +729,8 @@
          */
        virtual void                    setConstant (uint index, float, float, 
float, float) =0;
        virtual void                    setConstant (uint index, double, 
double, double, double) =0;
-       virtual void                    setConstant (uint index, const 
NLMISC::CVector* value) =0;
-       virtual void                    setConstant (uint index, const 
NLMISC::CVectorD* value) =0;
+       virtual void                    setConstant (uint index, const 
NLMISC::CVector& value) =0;
+       virtual void                    setConstant (uint index, const 
NLMISC::CVectorD& value) =0;
        /// setup several 4 float csts taken from the given tab
        virtual void                    setConstant (uint index, uint num, 
const float *src) =0;
        /// setup several 4 double csts taken from the given tab
--- nel.orig/src/3d/landscape.cpp
+++ nel/src/3d/landscape.cpp
@@ -1062,13 +1062,13 @@
                // c[4] take usefull constants.
                driver->setConstant(4, 0, 1, 0.5f, 0);
                // c[5] take RefineCenter
-               driver->setConstant(5, &refineCenter);
+               driver->setConstant(5, refineCenter);
                // c[6] take info for Geomorph trnasition to TileNear.
                driver->setConstant(6, CLandscapeGlobals::TileDistFarSqr, 
CLandscapeGlobals::OOTileDistDeltaSqr, 0, 0);
                // c[8..11] take the ModelView Matrix.
                driver->setConstantMatrix(8, IDriver::ModelView, 
IDriver::Identity);
                // c[12] take the current landscape Center / delta Pos to apply
-               driver->setConstant(12, &_PZBModelPosition);
+               driver->setConstant(12, _PZBModelPosition);
        }
 
 
--- nel.orig/src/3d/meshvp_per_pixel_light.cpp
+++ nel/src/3d/meshvp_per_pixel_light.cpp
@@ -425,7 +425,7 @@
                {
                        // put light direction in object space
                        NLMISC::CVector lPos = 
invertedModelMat.mulVector(strongestLight.getDirection());
-                       drv->setConstant(4, &lPos);
+                       drv->setConstant(4, lPos);
                        _IsPointLight = false;
                }
                break;
@@ -433,7 +433,7 @@
                {
                        // put light in object space
                        NLMISC::CVector lPos = invertedModelMat * 
strongestLight.getPosition();
-                       drv->setConstant(4, &lPos);
+                       drv->setConstant(4, lPos);
                        _IsPointLight = true;
                }
                break;
@@ -447,7 +447,7 @@
        {
                // viewer pos in object space
                NLMISC::CVector vPos = invertedModelMat * viewerPos;
-               drv->setConstant(5, &vPos);
+               drv->setConstant(5, vPos);
        }
                
        // c[0..3] take the ModelViewProjection Matrix. After 
setupModelMatrix();
--- nel.orig/src/3d/meshvp_wind_tree.cpp
+++ nel/src/3d/meshvp_wind_tree.cpp
@@ -248,7 +248,7 @@
        float   f;
        f= _CurrentTime[0] + instancePhase;
        f= speedCos(f) + Bias[0];
-       driver->setConstant(15, &(maxDeltaPosOS[0]*f) );
+       driver->setConstant(15, maxDeltaPosOS[0]*f );
 
 
        // c[16-19] take Wind of level 1.
@@ -256,16 +256,16 @@
        float   instTime1= _CurrentTime[1] + instancePhase;
        // phase 0.
        f= speedCos( instTime1+0 ) + Bias[1];
-       driver->setConstant(16+0, &(maxDeltaPosOS[1]*f));
+       driver->setConstant(16+0, maxDeltaPosOS[1]*f);
        // phase 1.
        f= speedCos( instTime1+0.25f ) + Bias[1];
-       driver->setConstant(16+1, &(maxDeltaPosOS[1]*f));
+       driver->setConstant(16+1, maxDeltaPosOS[1]*f);
        // phase 2.
        f= speedCos( instTime1+0.50f ) + Bias[1];
-       driver->setConstant(16+2, &(maxDeltaPosOS[1]*f));
+       driver->setConstant(16+2, maxDeltaPosOS[1]*f);
        // phase 3.
        f= speedCos( instTime1+0.75f ) + Bias[1];
-       driver->setConstant(16+3, &(maxDeltaPosOS[1]*f));
+       driver->setConstant(16+3, maxDeltaPosOS[1]*f);
 
 
        // c[20, 23] take Wind of level 2.
@@ -273,16 +273,16 @@
        float   instTime2= _CurrentTime[2] + instancePhase;
        // phase 0.
        f= speedCos( instTime2+0 ) + Bias[2];
-       driver->setConstant(20+0, &(maxDeltaPosOS[2]*f));
+       driver->setConstant(20+0, maxDeltaPosOS[2]*f);
        // phase 1.
        f= speedCos( instTime2+0.25f ) + Bias[2];
-       driver->setConstant(20+1, &(maxDeltaPosOS[2]*f));
+       driver->setConstant(20+1, maxDeltaPosOS[2]*f);
        // phase 2.
        f= speedCos( instTime2+0.50f ) + Bias[2];
-       driver->setConstant(20+2, &(maxDeltaPosOS[2]*f));
+       driver->setConstant(20+2, maxDeltaPosOS[2]*f);
        // phase 3.
        f= speedCos( instTime2+0.75f ) + Bias[2];
-       driver->setConstant(20+3, &(maxDeltaPosOS[2]*f));
+       driver->setConstant(20+3, maxDeltaPosOS[2]*f);
 
 
        // Activate the good VertexProgram
--- nel.orig/src/3d/render_trav.cpp
+++ nel/src/3d/render_trav.cpp
@@ -562,12 +562,12 @@
        if(supportSpecular)
        {
                // Setup lightDir.
-               Driver->setConstant(_VPCurrentCtStart+9, &lightDir);
+               Driver->setConstant(_VPCurrentCtStart+9, lightDir);
        }
        else
        {
                // Setup lightDir. NB: no specular color!
-               Driver->setConstant(_VPCurrentCtStart+5, &lightDir);
+               Driver->setConstant(_VPCurrentCtStart+5, lightDir);
        }
 
 
@@ -578,7 +578,7 @@
        if(supportSpecular)
        {
                // Setup eye in objectSpace for localViewer
-               Driver->setConstant(_VPCurrentCtStart+11, &eye);
+               Driver->setConstant(_VPCurrentCtStart+11, eye);
                // Start at 12.
                startPLPos= 12;
        }
@@ -593,7 +593,7 @@
                // Setup position of light.
                CVector         lightPos;
                lightPos= invObjectWM * _DriverLight[i].getPosition();
-               Driver->setConstant(_VPCurrentCtStart+startPLPos+(i-1), 
&lightPos);
+               Driver->setConstant(_VPCurrentCtStart+startPLPos+(i-1), 
lightPos);
        }
 
 
--- nel.orig/src/3d/vegetable_manager.cpp
+++ nel/src/3d/vegetable_manager.cpp
@@ -1749,9 +1749,9 @@
        // c[8] take usefull constants.
        driver->setConstant(8, 0, 1, 0.5f, 2);
        // c[9] take normalized directional light
-       driver->setConstant(9, &_DirectionalLight);
+       driver->setConstant(9, _DirectionalLight);
        // c[10] take pos of camera
-       driver->setConstant(10, &_ViewCenter);
+       driver->setConstant(10, _ViewCenter);
        // c[11] take factor for Blend formula
        driver->setConstant(11, 
-1.f/NL3D_VEGETABLE_BLOCK_BLEND_TRANSITION_DIST, 0, 0, 0);
 
--- nel.orig/src/3d/driver/opengl/driver_opengl.h
+++ nel/src/3d/driver/opengl/driver_opengl.h
@@ -902,8 +902,8 @@
        bool                    activeVertexProgram (CVertexProgram *program);
        void                    setConstant (uint index, float, float, float, 
float);
        void                    setConstant (uint index, double, double, 
double, double);
-       void                    setConstant (uint indexStart, const 
NLMISC::CVector* value);
-       void                    setConstant (uint indexStart, const 
NLMISC::CVectorD* value);   
+       void                    setConstant (uint indexStart, const 
NLMISC::CVector& value);
+       void                    setConstant (uint indexStart, const 
NLMISC::CVectorD& value);   
        void                    setConstant (uint index, uint num, const float 
*src);   
        void                    setConstant (uint index, uint num, const double 
*src);
        void                    setConstantMatrix (uint index, IDriver::TMatrix 
matrix, IDriver::TTransform transform); 
--- nel.orig/src/3d/driver/opengl/driver_opengl_vertex_program.cpp
+++ nel/src/3d/driver/opengl/driver_opengl_vertex_program.cpp
@@ -203,26 +203,26 @@
 
 // ***************************************************************************
 
-void CDriverGL::setConstant (uint index, const NLMISC::CVector* value)
+void CDriverGL::setConstant (uint index, const NLMISC::CVector& value)
 {
        // Vertex program exist ?
        if (_Extensions.NVVertexProgram)
        {
                // Setup constant
-               nglProgramParameter4fNV (GL_VERTEX_PROGRAM_NV, index, value->x, 
value->y, value->z, 0);
+               nglProgramParameter4fNV (GL_VERTEX_PROGRAM_NV, index, value.x, 
value.y, value.z, 0);
        }
 }
 
 
 // ***************************************************************************
 
-void CDriverGL::setConstant (uint index, const NLMISC::CVectorD* value)
+void CDriverGL::setConstant (uint index, const NLMISC::CVectorD& value)
 {
        // Vertex program exist ?
        if (_Extensions.NVVertexProgram)
        {
                // Setup constant
-               nglProgramParameter4dNV (GL_VERTEX_PROGRAM_NV, index, value->x, 
value->y, value->z, 0);
+               nglProgramParameter4dNV (GL_VERTEX_PROGRAM_NV, index, value.x, 
value.y, value.z, 0);
        }
 }
 
--- nel.orig/src/sound/audio_mixer_user.cpp
+++ nel/src/sound/audio_mixer_user.cpp
@@ -712,7 +712,7 @@
        string path = _SamplePath;
        path.append("/").append(filename);
 
-       nldebug( "Loading samples from %s...", path );
+       nldebug( "Loading samples from %s...", path.c_str() );
 
        CSampleBank* bank = new CSampleBank(path, _SoundDriver);
 
--- nel.orig/src/misc/eval_num_expr.cpp
+++ nel/src/misc/eval_num_expr.cpp
@@ -96,7 +96,7 @@
 CEvalNumExpr::TReturnState CEvalNumExpr::getNextToken (TToken &token)
 {
        // Get the current char
-       char currentChar = *_ExprPtr;
+       uint8 currentChar = *_ExprPtr;
 
        // Skip space
        while ((currentChar!=0) && (currentChar<=0x20))
@@ -1316,4 +1316,4 @@
 
 // ***************************************************************************
 
-}
\ No newline at end of file
+}
 
-- 
Loic   Dachary         http://www.dachary.org/  address@hidden
12 bd  Magenta         http://www.senga.org/      address@hidden
75010    Paris         T: 33 1 42 45 07 97          address@hidden
        GPG Public Key: http://www.dachary.org/loic/gpg.txt




reply via email to

[Prev in Thread] Current Thread [Next in Thread]