Changeset 8804

Show
Ignore:
Timestamp:
08/28/08 11:43:00
Author:
robert
Message:

Converted AutoTransform? to use doubles.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • OpenSceneGraph/trunk/include/osg/AutoTransform

    r8734 r8804  
    4343        virtual const AutoTransform* asAutoTransform() const { return this; } 
    4444 
    45         inline void setPosition(const Vec3& pos) { _position = pos; _matrixDirty=true; dirtyBound(); } 
    46         inline const Vec3& getPosition() const { return _position; } 
     45        inline void setPosition(const Vec3d& pos) { _position = pos; _matrixDirty=true; dirtyBound(); } 
     46        inline const Vec3d& getPosition() const { return _position; } 
    4747 
    4848 
     
    5050        inline const Quat& getRotation() const { return _rotation; } 
    5151 
    52         inline void setScale(float scale) { setScale(osg::Vec3(scale,scale,scale)); } 
     52        inline void setScale(double scale) { setScale(osg::Vec3(scale,scale,scale)); } 
    5353 
    54         void setScale(const Vec3& scale); 
    55         inline const Vec3& getScale() const { return _scale; } 
     54        void setScale(const Vec3d& scale); 
     55        inline const Vec3d& getScale() const { return _scale; } 
    5656 
    57         void setMinimumScale(float minimumScale) { _minimumScale = minimumScale; } 
    58         float getMinimumScale() const { return _minimumScale; } 
     57        void setMinimumScale(double minimumScale) { _minimumScale = minimumScale; } 
     58        double getMinimumScale() const { return _minimumScale; } 
    5959 
    60         void setMaximumScale(float maximumScale) { _maximumScale = maximumScale; } 
    61         float getMaximumScale() const { return _maximumScale; } 
     60        void setMaximumScale(double maximumScale) { _maximumScale = maximumScale; } 
     61        double getMaximumScale() const { return _maximumScale; } 
    6262 
    63         inline void setPivotPoint(const Vec3& pivot) { _pivotPoint = pivot; _matrixDirty=true; dirtyBound(); } 
    64         inline const Vec3& getPivotPoint() const { return _pivotPoint; } 
     63        inline void setPivotPoint(const Vec3d& pivot) { _pivotPoint = pivot; _matrixDirty=true; dirtyBound(); } 
     64        inline const Vec3d& getPivotPoint() const { return _pivotPoint; } 
    6565 
    6666 
     
    9999        virtual ~AutoTransform() {} 
    100100 
    101         Vec3                            _position; 
    102         Vec3                            _pivotPoint; 
    103         float                           _autoUpdateEyeMovementTolerance; 
     101        Vec3d                           _position; 
     102        Vec3d                           _pivotPoint; 
     103        double                          _autoUpdateEyeMovementTolerance; 
    104104 
    105105        AutoRotateMode                  _autoRotateMode; 
     
    108108 
    109109        mutable Quat                    _rotation; 
    110         mutable Vec3                    _scale; 
     110        mutable Vec3d                   _scale; 
    111111        mutable bool                    _firstTimeToInitEyePoint; 
    112112        mutable osg::Vec3               _previousEyePoint; 
     
    114114        mutable Viewport::value_type    _previousWidth; 
    115115        mutable Viewport::value_type    _previousHeight; 
    116         mutable osg::Matrix             _previousProjection; 
    117         mutable osg::Vec3               _previousPosition; 
     116        mutable osg::Matrixd            _previousProjection; 
     117        mutable osg::Vec3d              _previousPosition; 
    118118 
    119         float                           _minimumScale; 
    120         float                           _maximumScale; 
    121         float                           _autoScaleTransitionWidthRatio; 
     119        double                          _minimumScale; 
     120        double                          _maximumScale; 
     121        double                          _autoScaleTransitionWidthRatio; 
    122122 
    123123        void computeMatrix() const; 
    124124 
    125         mutable bool        _matrixDirty; 
    126         mutable osg::Matrix _cachedMatrix; 
     125        mutable bool                    _matrixDirty; 
     126        mutable osg::Matrixd            _cachedMatrix; 
    127127}; 
    128128 
  • OpenSceneGraph/trunk/src/osg/AutoTransform.cpp

    r7968 r8804  
    1919 
    2020AutoTransform::AutoTransform(): 
    21     _autoUpdateEyeMovementTolerance(0.0f), 
     21    _autoUpdateEyeMovementTolerance(0.0), 
    2222    _autoRotateMode(NO_ROTATION), 
    2323    _autoScaleToScreen(false), 
    24     _scale(1.0f,1.0f,1.0f), 
     24    _scale(1.0,1.0,1.0), 
    2525    _firstTimeToInitEyePoint(true), 
    26     _minimumScale(0.0f), 
    27     _maximumScale(FLT_MAX), 
    28     _autoScaleTransitionWidthRatio(0.25f), 
     26    _minimumScale(0.0), 
     27    _maximumScale(DBL_MAX), 
     28    _autoScaleTransitionWidthRatio(0.25), 
    2929    _matrixDirty(true) 
    3030{ 
     
    5050} 
    5151 
    52 void AutoTransform::setScale(const Vec3& scale) 
     52void AutoTransform::setScale(const Vec3d& scale) 
    5353{ 
    5454    _scale = scale;  
     
    8888        matrix.postMult(osg::Matrix::translate(-_position)* 
    8989                        osg::Matrix::rotate(_rotation.inverse())* 
    90                         osg::Matrix::scale(1.0f/_scale.x(),1.0f/_scale.y(),1.0f/_scale.z())* 
     90                        osg::Matrix::scale(1.0/_scale.x(),1.0/_scale.y(),1.0/_scale.z())* 
    9191                        osg::Matrix::translate(_pivotPoint)); 
    9292    } 
     
    9595        matrix = osg::Matrix::translate(-_position)* 
    9696                 osg::Matrix::rotate(_rotation.inverse())* 
    97                  osg::Matrix::scale(1.0f/_scale.x(),1.0f/_scale.y(),1.0f/_scale.z())* 
     97                 osg::Matrix::scale(1.0/_scale.x(),1.0/_scale.y(),1.0/_scale.z())* 
    9898                 osg::Matrix::translate(_pivotPoint); 
    9999    } 
     
    139139                } 
    140140 
    141                 osg::Vec3 eyePoint = cs->getEyeLocal();  
    142                 osg::Vec3 localUp = cs->getUpLocal();  
    143                 osg::Vec3 position = getPosition(); 
     141                osg::Vec3d eyePoint = cs->getEyeLocal();  
     142                osg::Vec3d localUp = cs->getUpLocal();  
     143                osg::Vec3d position = getPosition(); 
    144144 
    145145                const osg::Matrix& projection = *(cs->getProjectionMatrix()); 
     
    148148                if (!_firstTimeToInitEyePoint) 
    149149                { 
    150                     osg::Vec3 dv = _previousEyePoint-eyePoint; 
     150                    osg::Vec3d dv = _previousEyePoint-eyePoint; 
    151151                    if (dv.length2()>getAutoUpdateEyeMovementTolerance()*(eyePoint-getPosition()).length2()) 
    152152                    { 
    153153                        doUpdate = true; 
    154154                    } 
    155                     osg::Vec3 dupv = _previousLocalUp-localUp; 
     155                    osg::Vec3d dupv = _previousLocalUp-localUp; 
    156156                    // rotating the camera only affects ROTATE_TO_* 
    157157                    if (_autoRotateMode && 
     
    180180                    if (getAutoScaleToScreen()) 
    181181                    { 
    182                         float size = 1.0f/cs->pixelSize(getPosition(),0.48f); 
    183  
    184                         if (_autoScaleTransitionWidthRatio>0.0f
     182                        double size = 1.0/cs->pixelSize(getPosition(),0.48); 
     183 
     184                        if (_autoScaleTransitionWidthRatio>0.0
    185185                        {  
    186                             if (_minimumScale>0.0f
     186                            if (_minimumScale>0.0
    187187                            { 
    188                                 float j = _minimumScale; 
    189                                 float i = (_maximumScale<FLT_MAX) ?  
     188                                double j = _minimumScale; 
     189                                double i = (_maximumScale<DBL_MAX) ?  
    190190                                            _minimumScale+(_maximumScale-_minimumScale)*_autoScaleTransitionWidthRatio : 
    191                                             _minimumScale*(1.0f+_autoScaleTransitionWidthRatio); 
    192                                 float c = 1.0f/(4.0f*(i-j)); 
    193                                 float b = 1.0f - 2.0f*c*i; 
    194                                 float a = j + b*b / (4.0f*c); 
    195                                 float k = -b / (2.0f*c); 
     191                                            _minimumScale*(1.0+_autoScaleTransitionWidthRatio); 
     192                                double c = 1.0/(4.0*(i-j)); 
     193                                double b = 1.0 - 2.0*c*i; 
     194                                double a = j + b*b / (4.0*c); 
     195                                double k = -b / (2.0*c); 
    196196 
    197197                                if (size<k) size = _minimumScale; 
     
    199199                            } 
    200200 
    201                             if (_maximumScale<FLT_MAX) 
     201                            if (_maximumScale<DBL_MAX) 
    202202                            { 
    203                                 float n = _maximumScale; 
    204                                 float m = (_minimumScale>0.0) ? 
     203                                double n = _maximumScale; 
     204                                double m = (_minimumScale>0.0) ? 
    205205                                            _maximumScale+(_minimumScale-_maximumScale)*_autoScaleTransitionWidthRatio : 
    206                                             _maximumScale*(1.0f-_autoScaleTransitionWidthRatio); 
    207                                 float c = 1.0f / (4.0f*(m-n)); 
    208                                 float b = 1.0f - 2.0f*c*m; 
    209                                 float a = n + b*b/(4.0f*c); 
    210                                 float p = -b / (2.0f*c); 
     206                                            _maximumScale*(1.0-_autoScaleTransitionWidthRatio); 
     207                                double c = 1.0 / (4.0*(m-n)); 
     208                                double b = 1.0 - 2.0*c*m; 
     209                                double a = n + b*b/(4.0*c); 
     210                                double p = -b / (2.0*c); 
    211211 
    212212                                if (size>p) size = _maximumScale; 
     
    231231                    else if (_autoRotateMode==ROTATE_TO_CAMERA) 
    232232                    { 
    233                         osg::Vec3 PosToEye = _position - eyePoint; 
     233                        osg::Vec3d PosToEye = _position - eyePoint; 
    234234                        osg::Matrix lookto = osg::Matrix::lookAt( 
    235                             osg::Vec3(0,0,0), PosToEye, localUp); 
     235                            osg::Vec3d(0,0,0), PosToEye, localUp); 
    236236                        Quat q; 
    237237                        q.set(osg::Matrix::inverse(lookto)); 
  • OpenSceneGraph/trunk/src/osgWrappers/osg/AutoTransform.cpp

    r8734 r8804  
    1818#include <osg/Object> 
    1919#include <osg/Quat> 
    20 #include <osg/Vec3
     20#include <osg/Vec3d
    2121 
    2222// Must undefine IN and OUT macros defined in Windows headers 
     
    8585                  "", 
    8686                  ""); 
    87         I_Method1(void, setPosition, IN, const osg::Vec3 &, pos, 
    88                   Properties::NON_VIRTUAL, 
    89                   __void__setPosition__C5_Vec3_R1, 
    90                   "", 
    91                   ""); 
    92         I_Method0(const osg::Vec3 &, getPosition, 
    93                   Properties::NON_VIRTUAL, 
    94                   __C5_Vec3_R1__getPosition, 
     87        I_Method1(void, setPosition, IN, const osg::Vec3d &, pos, 
     88                  Properties::NON_VIRTUAL, 
     89                  __void__setPosition__C5_Vec3d_R1, 
     90                  "", 
     91                  ""); 
     92        I_Method0(const osg::Vec3d &, getPosition, 
     93                  Properties::NON_VIRTUAL, 
     94                  __C5_Vec3d_R1__getPosition, 
    9595                  "", 
    9696                  ""); 
     
    105105                  "", 
    106106                  ""); 
    107         I_Method1(void, setScale, IN, float, scale, 
    108                   Properties::NON_VIRTUAL, 
    109                   __void__setScale__float
    110                   "", 
    111                   ""); 
    112         I_Method1(void, setScale, IN, const osg::Vec3 &, scale, 
    113                   Properties::NON_VIRTUAL, 
    114                   __void__setScale__C5_Vec3_R1, 
    115                   "", 
    116                   ""); 
    117         I_Method0(const osg::Vec3 &, getScale, 
    118                   Properties::NON_VIRTUAL, 
    119                   __C5_Vec3_R1__getScale, 
    120                   "", 
    121                   ""); 
    122         I_Method1(void, setMinimumScale, IN, float, minimumScale, 
    123                   Properties::NON_VIRTUAL, 
    124                   __void__setMinimumScale__float
    125                   "", 
    126                   ""); 
    127         I_Method0(float, getMinimumScale, 
    128                   Properties::NON_VIRTUAL, 
    129                   __float__getMinimumScale, 
    130                   "", 
    131                   ""); 
    132         I_Method1(void, setMaximumScale, IN, float, maximumScale, 
    133                   Properties::NON_VIRTUAL, 
    134                   __void__setMaximumScale__float
    135                   "", 
    136                   ""); 
    137         I_Method0(float, getMaximumScale, 
    138                   Properties::NON_VIRTUAL, 
    139                   __float__getMaximumScale, 
    140                   "", 
    141                   ""); 
    142         I_Method1(void, setPivotPoint, IN, const osg::Vec3 &, pivot, 
    143                   Properties::NON_VIRTUAL, 
    144                   __void__setPivotPoint__C5_Vec3_R1, 
    145                   "", 
    146                   ""); 
    147         I_Method0(const osg::Vec3 &, getPivotPoint, 
    148                   Properties::NON_VIRTUAL, 
    149                   __C5_Vec3_R1__getPivotPoint, 
     107        I_Method1(void, setScale, IN, double, scale, 
     108                  Properties::NON_VIRTUAL, 
     109                  __void__setScale__double
     110                  "", 
     111                  ""); 
     112        I_Method1(void, setScale, IN, const osg::Vec3d &, scale, 
     113                  Properties::NON_VIRTUAL, 
     114                  __void__setScale__C5_Vec3d_R1, 
     115                  "", 
     116                  ""); 
     117        I_Method0(const osg::Vec3d &, getScale, 
     118                  Properties::NON_VIRTUAL, 
     119                  __C5_Vec3d_R1__getScale, 
     120                  "", 
     121                  ""); 
     122        I_Method1(void, setMinimumScale, IN, double, minimumScale, 
     123                  Properties::NON_VIRTUAL, 
     124                  __void__setMinimumScale__double
     125                  "", 
     126                  ""); 
     127        I_Method0(double, getMinimumScale, 
     128                  Properties::NON_VIRTUAL, 
     129                  __double__getMinimumScale, 
     130                  "", 
     131                  ""); 
     132        I_Method1(void, setMaximumScale, IN, double, maximumScale, 
     133                  Properties::NON_VIRTUAL, 
     134                  __void__setMaximumScale__double
     135                  "", 
     136                  ""); 
     137        I_Method0(double, getMaximumScale, 
     138                  Properties::NON_VIRTUAL, 
     139                  __double__getMaximumScale, 
     140                  "", 
     141                  ""); 
     142        I_Method1(void, setPivotPoint, IN, const osg::Vec3d &, pivot, 
     143                  Properties::NON_VIRTUAL, 
     144                  __void__setPivotPoint__C5_Vec3d_R1, 
     145                  "", 
     146                  ""); 
     147        I_Method0(const osg::Vec3d &, getPivotPoint, 
     148                  Properties::NON_VIRTUAL, 
     149                  __C5_Vec3d_R1__getPivotPoint, 
    150150                  "", 
    151151                  ""); 
     
    223223                         __float__getAutoUpdateEyeMovementTolerance,  
    224224                         __void__setAutoUpdateEyeMovementTolerance__float); 
    225         I_SimpleProperty(float, MaximumScale,  
    226                          __float__getMaximumScale,  
    227                          __void__setMaximumScale__float); 
    228         I_SimpleProperty(float, MinimumScale,  
    229                          __float__getMinimumScale,  
    230                          __void__setMinimumScale__float); 
    231         I_SimpleProperty(const osg::Vec3 &, PivotPoint,  
    232                          __C5_Vec3_R1__getPivotPoint,  
    233                          __void__setPivotPoint__C5_Vec3_R1); 
    234         I_SimpleProperty(const osg::Vec3 &, Position,  
    235                          __C5_Vec3_R1__getPosition,  
    236                          __void__setPosition__C5_Vec3_R1); 
     225        I_SimpleProperty(double, MaximumScale,  
     226                         __double__getMaximumScale,  
     227                         __void__setMaximumScale__double); 
     228        I_SimpleProperty(double, MinimumScale,  
     229                         __double__getMinimumScale,  
     230                         __void__setMinimumScale__double); 
     231        I_SimpleProperty(const osg::Vec3d &, PivotPoint,  
     232                         __C5_Vec3d_R1__getPivotPoint,  
     233                         __void__setPivotPoint__C5_Vec3d_R1); 
     234        I_SimpleProperty(const osg::Vec3d &, Position,  
     235                         __C5_Vec3d_R1__getPosition,  
     236                         __void__setPosition__C5_Vec3d_R1); 
    237237        I_SimpleProperty(const osg::Quat &, Rotation,  
    238238                         __C5_Quat_R1__getRotation,  
    239239                         __void__setRotation__C5_Quat_R1); 
    240         I_SimpleProperty(const osg::Vec3 &, Scale,  
    241                          __C5_Vec3_R1__getScale,  
    242                          __void__setScale__C5_Vec3_R1); 
     240        I_SimpleProperty(const osg::Vec3d &, Scale,  
     241                         __C5_Vec3d_R1__getScale,  
     242                         __void__setScale__C5_Vec3d_R1); 
    243243END_REFLECTOR 
    244244 
  • OpenSceneGraph/trunk/src/osgWrappers/osgTerrain/Layer.cpp

    r7872 r8804  
    870870END_REFLECTOR 
    871871 
     872BEGIN_OBJECT_REFLECTOR(osgTerrain::SwitchLayer) 
     873        I_DeclaringFile("osgTerrain/Layer"); 
     874        I_BaseType(osgTerrain::Layer); 
     875        I_Constructor0(____SwitchLayer, 
     876                       "", 
     877                       ""); 
     878        I_ConstructorWithDefaults2(IN, const osgTerrain::SwitchLayer &, switchLayer, , IN, const osg::CopyOp &, copyop, osg::CopyOp::SHALLOW_COPY, 
     879                                   ____SwitchLayer__C5_SwitchLayer_R1__C5_osg_CopyOp_R1, 
     880                                   "Copy constructor using CopyOp to manage deep vs shallow copy. ", 
     881                                   ""); 
     882        I_Method0(osg::Object *, cloneType, 
     883                  Properties::VIRTUAL, 
     884                  __osg_Object_P1__cloneType, 
     885                  "Clone the type of an object, with Object* return type. ", 
     886                  "Must be defined by derived classes. "); 
     887        I_Method1(osg::Object *, clone, IN, const osg::CopyOp &, copyop, 
     888                  Properties::VIRTUAL, 
     889                  __osg_Object_P1__clone__C5_osg_CopyOp_R1, 
     890                  "Clone an object, with Object* return type. ", 
     891                  "Must be defined by derived classes. "); 
     892        I_Method1(bool, isSameKindAs, IN, const osg::Object *, obj, 
     893                  Properties::VIRTUAL, 
     894                  __bool__isSameKindAs__C5_osg_Object_P1, 
     895                  "", 
     896                  ""); 
     897        I_Method0(const char *, libraryName, 
     898                  Properties::VIRTUAL, 
     899                  __C5_char_P1__libraryName, 
     900                  "return the name of the object's library. ", 
     901                  "Must be defined by derived classes. The OpenSceneGraph convention is that the namespace of a library is the same as the library name. "); 
     902        I_Method0(const char *, className, 
     903                  Properties::VIRTUAL, 
     904                  __C5_char_P1__className, 
     905                  "return the name of the object's class type. ", 
     906                  "Must be defined by derived classes. "); 
     907        I_Method0(void, clear, 
     908                  Properties::NON_VIRTUAL, 
     909                  __void__clear, 
     910                  "", 
     911                  ""); 
     912        I_Method1(void, setActiveLayer, IN, unsigned int, i, 
     913                  Properties::NON_VIRTUAL, 
     914                  __void__setActiveLayer__unsigned_int, 
     915                  "", 
     916                  ""); 
     917        I_Method0(unsigned int, getActiveLayer, 
     918                  Properties::NON_VIRTUAL, 
     919                  __unsigned_int__getActiveLayer, 
     920                  "", 
     921                  ""); 
     922        I_Method2(void, setFileName, IN, unsigned int, i, IN, const std::string &, filename, 
     923                  Properties::NON_VIRTUAL, 
     924                  __void__setFileName__unsigned_int__C5_std_string_R1, 
     925                  "", 
     926                  ""); 
     927        I_Method1(const std::string &, getFileName, IN, unsigned int, i, 
     928                  Properties::NON_VIRTUAL, 
     929                  __C5_std_string_R1__getFileName__unsigned_int, 
     930                  "", 
     931                  ""); 
     932        I_Method2(void, setLayer, IN, unsigned int, i, IN, osgTerrain::Layer *, layer, 
     933                  Properties::NON_VIRTUAL, 
     934                  __void__setLayer__unsigned_int__Layer_P1, 
     935                  "", 
     936                  ""); 
     937        I_Method1(osgTerrain::Layer *, getLayer, IN, unsigned int, i, 
     938                  Properties::NON_VIRTUAL, 
     939                  __Layer_P1__getLayer__unsigned_int, 
     940                  "", 
     941                  ""); 
     942        I_Method1(const osgTerrain::Layer *, getLayer, IN, unsigned int, i, 
     943                  Properties::NON_VIRTUAL, 
     944                  __C5_Layer_P1__getLayer__unsigned_int, 
     945                  "", 
     946                  ""); 
     947        I_Method1(void, addLayer, IN, const std::string &, filename, 
     948                  Properties::NON_VIRTUAL, 
     949                  __void__addLayer__C5_std_string_R1, 
     950                  "", 
     951                  ""); 
     952        I_Method1(void, addLayer, IN, osgTerrain::Layer *, layer, 
     953                  Properties::NON_VIRTUAL, 
     954                  __void__addLayer__Layer_P1, 
     955                  "", 
     956                  ""); 
     957        I_Method1(void, removeLayer, IN, unsigned int, i, 
     958                  Properties::NON_VIRTUAL, 
     959                  __void__removeLayer__unsigned_int, 
     960                  "", 
     961                  ""); 
     962        I_Method0(unsigned int, getNumLayers, 
     963                  Properties::NON_VIRTUAL, 
     964                  __unsigned_int__getNumLayers, 
     965                  "", 
     966                  ""); 
     967        I_SimpleProperty(unsigned int, ActiveLayer,  
     968                         __unsigned_int__getActiveLayer,  
     969                         __void__setActiveLayer__unsigned_int); 
     970        I_IndexedProperty(const std::string &, FileName,  
     971                          __C5_std_string_R1__getFileName__unsigned_int,  
     972                          __void__setFileName__unsigned_int__C5_std_string_R1,  
     973                          0); 
     974        I_ArrayProperty(osgTerrain::Layer *, Layer,  
     975                        __Layer_P1__getLayer__unsigned_int,  
     976                        __void__setLayer__unsigned_int__Layer_P1,  
     977                        __unsigned_int__getNumLayers,  
     978                        __void__addLayer__Layer_P1,  
     979                        0,  
     980                        __void__removeLayer__unsigned_int); 
     981END_REFLECTOR 
     982