llprimitive.h

Go to the documentation of this file.
00001 
00032 #ifndef LL_LLPRIMITIVE_H
00033 #define LL_LLPRIMITIVE_H
00034 
00035 #include "lluuid.h"
00036 #include "v3math.h"
00037 #include "xform.h"
00038 #include "message.h"
00039 #include "llmemory.h"
00040 #include "llvolume.h"
00041 #include "lltextureentry.h"
00042 
00043 // Moved to stdtypes.h --JC
00044 // typedef U8 LLPCode;
00045 class LLMessageSystem;
00046 class LLVolumeParams;
00047 class LLColor4;
00048 class LLColor3;
00049 class LLTextureEntry;
00050 class LLDataPacker;
00051 class LLVolumeMgr;
00052 
00053 enum LLGeomType // NOTE: same vals as GL Ids
00054 {
00055         LLInvalid   = 0,
00056         LLLineLoop  = 2,
00057         LLLineStrip = 3,
00058         LLTriangles = 4,
00059         LLTriStrip  = 5,
00060         LLTriFan    = 6,
00061         LLQuads     = 7, 
00062         LLQuadStrip = 8
00063 };
00064 
00065 class LLVolume;
00066 
00070 extern const F32 OBJECT_CUT_MIN;
00071 extern const F32 OBJECT_CUT_MAX;
00072 extern const F32 OBJECT_CUT_INC;
00073 extern const F32 OBJECT_MIN_CUT_INC;
00074 extern const F32 OBJECT_ROTATION_PRECISION;
00075 
00076 extern const F32 OBJECT_TWIST_MIN;
00077 extern const F32 OBJECT_TWIST_MAX;
00078 extern const F32 OBJECT_TWIST_INC;
00079 
00080 // This is used for linear paths,
00081 // since twist is used in a slightly different manner.
00082 extern const F32 OBJECT_TWIST_LINEAR_MIN;
00083 extern const F32 OBJECT_TWIST_LINEAR_MAX;
00084 extern const F32 OBJECT_TWIST_LINEAR_INC;
00085 
00086 extern const F32 OBJECT_MIN_HOLE_SIZE;
00087 extern const F32 OBJECT_MAX_HOLE_SIZE_X;
00088 extern const F32 OBJECT_MAX_HOLE_SIZE_Y;
00089 
00090 // Revolutions parameters.
00091 extern const F32 OBJECT_REV_MIN;
00092 extern const F32 OBJECT_REV_MAX;
00093 extern const F32 OBJECT_REV_INC;
00094 
00095 extern const char *SCULPT_DEFAULT_TEXTURE;
00096 
00097 //============================================================================
00098 
00099 // TomY: Base class for things that pack & unpack themselves
00100 class LLNetworkData
00101 {
00102 public:
00103         // Extra parameter IDs
00104         enum
00105         {
00106                 PARAMS_FLEXIBLE = 0x10,
00107                 PARAMS_LIGHT    = 0x20,
00108                 PARAMS_SCULPT   = 0x30
00109         };
00110         
00111 public:
00112         U16 mType;
00113         virtual ~LLNetworkData() {};
00114         virtual BOOL pack(LLDataPacker &dp) const = 0;
00115         virtual BOOL unpack(LLDataPacker &dp) = 0;
00116         virtual bool operator==(const LLNetworkData& data) const = 0;
00117         virtual void copy(const LLNetworkData& data) = 0;
00118         static BOOL isValid(U16 param_type, U32 size);
00119 };
00120 
00121 extern const F32 LIGHT_MIN_RADIUS;
00122 extern const F32 LIGHT_DEFAULT_RADIUS;
00123 extern const F32 LIGHT_MAX_RADIUS;
00124 extern const F32 LIGHT_MIN_FALLOFF;
00125 extern const F32 LIGHT_DEFAULT_FALLOFF;
00126 extern const F32 LIGHT_MAX_FALLOFF;
00127 extern const F32 LIGHT_MIN_CUTOFF;
00128 extern const F32 LIGHT_DEFAULT_CUTOFF;
00129 extern const F32 LIGHT_MAX_CUTOFF;
00130 
00131 class LLLightParams : public LLNetworkData
00132 {
00133 protected:
00134         LLColor4 mColor; // alpha = intensity
00135         F32 mRadius;
00136         F32 mFalloff;
00137         F32 mCutoff;
00138 
00139 public:
00140         LLLightParams();
00141         /*virtual*/ BOOL pack(LLDataPacker &dp) const;
00142         /*virtual*/ BOOL unpack(LLDataPacker &dp);
00143         /*virtual*/ bool operator==(const LLNetworkData& data) const;
00144         /*virtual*/ void copy(const LLNetworkData& data);
00145         // LLSD implementations here are provided by Eddy Stryker.
00146         // NOTE: there are currently unused in protocols
00147         LLSD asLLSD() const;
00148         operator LLSD() const { return asLLSD(); }
00149         bool fromLLSD(LLSD& sd);
00150 
00151         
00152         void setColor(const LLColor4& color)    { mColor = color; mColor.clamp(); }
00153         void setRadius(F32 radius)                              { mRadius = llclamp(radius, LIGHT_MIN_RADIUS, LIGHT_MAX_RADIUS); }
00154         void setFalloff(F32 falloff)                    { mFalloff = llclamp(falloff, LIGHT_MIN_FALLOFF, LIGHT_MAX_FALLOFF); }
00155         void setCutoff(F32 cutoff)                              { mCutoff = llclamp(cutoff, LIGHT_MIN_CUTOFF, LIGHT_MAX_CUTOFF); }
00156 
00157         LLColor4 getColor() const                               { return mColor; }
00158         F32 getRadius() const                                   { return mRadius; }
00159         F32 getFalloff() const                                  { return mFalloff; }
00160         F32 getCutoff() const                                   { return mCutoff; }
00161 };
00162 
00163 //-------------------------------------------------
00164 // This structure is also used in the part of the 
00165 // code that creates new flexible objects.
00166 //-------------------------------------------------
00167 
00168 // These were made into enums so that they could be used as fixed size
00169 // array bounds.
00170 enum EFlexibleObjectConst
00171 {
00172         // "Softness" => [0,3], increments of 1
00173         // Represents powers of 2: 0 -> 1, 3 -> 8
00174         FLEXIBLE_OBJECT_MIN_SECTIONS = 0,
00175         FLEXIBLE_OBJECT_DEFAULT_NUM_SECTIONS = 2,
00176         FLEXIBLE_OBJECT_MAX_SECTIONS = 3
00177 };
00178 
00179 // "Tension" => [0,10], increments of 0.1
00180 extern const F32 FLEXIBLE_OBJECT_MIN_TENSION;
00181 extern const F32 FLEXIBLE_OBJECT_DEFAULT_TENSION;
00182 extern const F32 FLEXIBLE_OBJECT_MAX_TENSION;
00183 
00184 // "Drag" => [0,10], increments of 0.1
00185 extern const F32 FLEXIBLE_OBJECT_MIN_AIR_FRICTION;
00186 extern const F32 FLEXIBLE_OBJECT_DEFAULT_AIR_FRICTION;
00187 extern const F32 FLEXIBLE_OBJECT_MAX_AIR_FRICTION;
00188 
00189 // "Gravity" = [-10,10], increments of 0.1
00190 extern const F32 FLEXIBLE_OBJECT_MIN_GRAVITY;
00191 extern const F32 FLEXIBLE_OBJECT_DEFAULT_GRAVITY;
00192 extern const F32 FLEXIBLE_OBJECT_MAX_GRAVITY;
00193 
00194 // "Wind" = [0,10], increments of 0.1
00195 extern const F32 FLEXIBLE_OBJECT_MIN_WIND_SENSITIVITY;
00196 extern const F32 FLEXIBLE_OBJECT_DEFAULT_WIND_SENSITIVITY;
00197 extern const F32 FLEXIBLE_OBJECT_MAX_WIND_SENSITIVITY;
00198 
00199 extern const F32 FLEXIBLE_OBJECT_MAX_INTERNAL_TENSION_FORCE;
00200 
00201 extern const F32 FLEXIBLE_OBJECT_DEFAULT_LENGTH;
00202 extern const BOOL FLEXIBLE_OBJECT_DEFAULT_USING_COLLISION_SPHERE;
00203 extern const BOOL FLEXIBLE_OBJECT_DEFAULT_RENDERING_COLLISION_SPHERE;
00204 
00205 
00206 class LLFlexibleObjectData : public LLNetworkData
00207 {
00208 protected:
00209         S32                     mSimulateLOD;           // 2^n = number of simulated sections
00210         F32                     mGravity;
00211         F32                     mAirFriction;           // higher is more stable, but too much looks like it's underwater
00212         F32                     mWindSensitivity;       // interacts with tension, air friction, and gravity
00213         F32                     mTension;                       //interacts in complex ways with other parameters
00214         LLVector3       mUserForce;                     // custom user-defined force vector
00215         //BOOL          mUsingCollisionSphere;
00216         //BOOL          mRenderingCollisionSphere;
00217 
00218 public:
00219         void            setSimulateLOD(S32 lod)                 { mSimulateLOD = llclamp(lod, (S32)FLEXIBLE_OBJECT_MIN_SECTIONS, (S32)FLEXIBLE_OBJECT_MAX_SECTIONS); }
00220         void            setGravity(F32 gravity)                 { mGravity = llclamp(gravity, FLEXIBLE_OBJECT_MIN_GRAVITY, FLEXIBLE_OBJECT_MAX_GRAVITY); }
00221         void            setAirFriction(F32 friction)    { mAirFriction = llclamp(friction, FLEXIBLE_OBJECT_MIN_AIR_FRICTION, FLEXIBLE_OBJECT_MAX_AIR_FRICTION); }
00222         void            setWindSensitivity(F32 wind)    { mWindSensitivity = llclamp(wind, FLEXIBLE_OBJECT_MIN_WIND_SENSITIVITY, FLEXIBLE_OBJECT_MAX_WIND_SENSITIVITY); }
00223         void            setTension(F32 tension)                 { mTension = llclamp(tension, FLEXIBLE_OBJECT_MIN_TENSION, FLEXIBLE_OBJECT_MAX_TENSION); }
00224         void            setUserForce(LLVector3 &force)  { mUserForce = force; }
00225 
00226         S32                     getSimulateLOD() const                  { return mSimulateLOD; }
00227         F32                     getGravity() const                              { return mGravity; }
00228         F32                     getAirFriction() const                  { return mAirFriction; }
00229         F32                     getWindSensitivity() const              { return mWindSensitivity; }
00230         F32                     getTension() const                              { return mTension; }
00231         LLVector3       getUserForce() const                    { return mUserForce; }
00232 
00233         //------ the constructor for the structure ------------
00234         LLFlexibleObjectData();
00235         BOOL pack(LLDataPacker &dp) const;
00236         BOOL unpack(LLDataPacker &dp);
00237         bool operator==(const LLNetworkData& data) const;
00238         void copy(const LLNetworkData& data);
00239         LLSD asLLSD() const;
00240         operator LLSD() const { return asLLSD(); }
00241         bool fromLLSD(LLSD& sd);
00242 };// end of attributes structure
00243 
00244 
00245 
00246 class LLSculptParams : public LLNetworkData
00247 {
00248 protected:
00249         LLUUID mSculptTexture;
00250         U8 mSculptType;
00251         
00252 public:
00253         LLSculptParams();
00254         /*virtual*/ BOOL pack(LLDataPacker &dp) const;
00255         /*virtual*/ BOOL unpack(LLDataPacker &dp);
00256         /*virtual*/ bool operator==(const LLNetworkData& data) const;
00257         /*virtual*/ void copy(const LLNetworkData& data);
00258         LLSD asLLSD() const;
00259         operator LLSD() const { return asLLSD(); }
00260         bool fromLLSD(LLSD& sd);
00261 
00262         void setSculptTexture(const LLUUID& id) { mSculptTexture = id; }
00263         LLUUID getSculptTexture()               { return mSculptTexture; }
00264         void setSculptType(U8 type)             { mSculptType = type; }
00265         U8 getSculptType()                      { return mSculptType; }
00266 };
00267 
00268 
00269 
00270 class LLPrimitive : public LLXform
00271 {
00272 public:
00273 
00274         // HACK for removing LLPrimitive's dependency on gVolumeMgr global.
00275         // If a different LLVolumeManager is instantiated and set early enough
00276         // then the LLPrimitive class will use it instead of gVolumeMgr.
00277         static LLVolumeMgr* getVolumeManager() { return sVolumeManager; }
00278         static void setVolumeManager( LLVolumeMgr* volume_manager);
00279         static bool cleanupVolumeManager();
00280 
00281         // these flags influence how the RigidBody representation is built
00282         static const U32 PRIM_FLAG_PHANTOM                              = 0x1 << 0;
00283         static const U32 PRIM_FLAG_VOLUME_DETECT                = 0x1 << 1;
00284         static const U32 PRIM_FLAG_DYNAMIC                              = 0x1 << 2;
00285         static const U32 PRIM_FLAG_AVATAR                               = 0x1 << 3;
00286         static const U32 PRIM_FLAG_SCULPT                               = 0x1 << 4;
00287         // not used yet, but soon
00288         static const U32 PRIM_FLAG_COLLISION_CALLBACK   = 0x1 << 5;
00289         static const U32 PRIM_FLAG_CONVEX                               = 0x1 << 6;
00290         static const U32 PRIM_FLAG_DEFAULT_VOLUME               = 0x1 << 7;
00291         static const U32 PRIM_FLAG_SITTING                              = 0x1 << 8;
00292         static const U32 PRIM_FLAG_SITTING_ON_GROUND    = 0x1 << 9;             // Set along with PRIM_FLAG_SITTING
00293 
00294         LLPrimitive();
00295         virtual ~LLPrimitive();
00296 
00297         static LLPrimitive *createPrimitive(LLPCode p_code);
00298         void init_primitive(LLPCode p_code);
00299 
00300         void setPCode(const LLPCode pcode);
00301         const LLVolume *getVolumeConst() const { return mVolumep; }             // HACK for Windoze confusion about ostream operator in LLVolume
00302         LLVolume *getVolume() const { return mVolumep; }
00303         virtual BOOL setVolume(const LLVolumeParams &volume_params, const S32 detail, bool unique_volume = false);
00304 
00305         // Modify texture entry properties
00306         inline BOOL validTE(const U8 te_num) const;
00307         const LLTextureEntry *getTE(const U8 te_num) const;
00308 
00309         virtual void setNumTEs(const U8 num_tes);
00310         virtual void setAllTETextures(const LLUUID &tex_id);
00311         virtual void setTE(const U8 index, const LLTextureEntry &te);
00312         virtual S32 setTEColor(const U8 te, const LLColor4 &color);
00313         virtual S32 setTEColor(const U8 te, const LLColor3 &color);
00314         virtual S32 setTEAlpha(const U8 te, const F32 alpha);
00315         virtual S32 setTETexture(const U8 te, const LLUUID &tex_id);
00316         virtual S32 setTEScale (const U8 te, const F32 s, const F32 t);
00317         virtual S32 setTEScaleS(const U8 te, const F32 s);
00318         virtual S32 setTEScaleT(const U8 te, const F32 t);
00319         virtual S32 setTEOffset (const U8 te, const F32 s, const F32 t);
00320         virtual S32 setTEOffsetS(const U8 te, const F32 s);
00321         virtual S32 setTEOffsetT(const U8 te, const F32 t);
00322         virtual S32 setTERotation(const U8 te, const F32 r);
00323         virtual S32 setTEBumpShinyFullbright(const U8 te, const U8 bump);
00324         virtual S32 setTEBumpShiny(const U8 te, const U8 bump);
00325         virtual S32 setTEMediaTexGen(const U8 te, const U8 media);
00326         virtual S32 setTEBumpmap(const U8 te, const U8 bump);
00327         virtual S32 setTETexGen(const U8 te, const U8 texgen);
00328         virtual S32 setTEShiny(const U8 te, const U8 shiny);
00329         virtual S32 setTEFullbright(const U8 te, const U8 fullbright);
00330         virtual S32 setTEMediaFlags(const U8 te, const U8 flags);
00331         virtual S32 setTEGlow(const U8 te, const F32 glow);
00332         virtual BOOL setMaterial(const U8 material); // returns TRUE if material changed
00333 
00334         void setTEArrays(const U8 size,
00335                                           const LLUUID* image_ids,
00336                                           const F32* scale_s,
00337                                           const F32* scale_t);
00338         void copyTEs(const LLPrimitive *primitive);
00339         S32 packTEField(U8 *cur_ptr, U8 *data_ptr, U8 data_size, U8 last_face_index, EMsgVariableType type) const;
00340         S32 unpackTEField(U8 *cur_ptr, U8 *buffer_end, U8 *data_ptr, U8 data_size, U8 face_count, EMsgVariableType type);
00341         BOOL packTEMessage(LLMessageSystem *mesgsys) const;
00342         BOOL packTEMessage(LLDataPacker &dp) const;
00343         S32 unpackTEMessage(LLMessageSystem *mesgsys, char *block_name);
00344         S32 unpackTEMessage(LLMessageSystem *mesgsys, char *block_name, const S32 block_num); // Variable num of blocks
00345         BOOL unpackTEMessage(LLDataPacker &dp);
00346         
00347 #ifdef CHECK_FOR_FINITE
00348         inline void setPosition(const LLVector3& pos);
00349         inline void setPosition(const F32 x, const F32 y, const F32 z);
00350         inline void addPosition(const LLVector3& pos);
00351 
00352         inline void setAngularVelocity(const LLVector3& avel);
00353         inline void setAngularVelocity(const F32 x, const F32 y, const F32 z);
00354         inline void setVelocity(const LLVector3& vel);
00355         inline void setVelocity(const F32 x, const F32 y, const F32 z);
00356         inline void setVelocityX(const F32 x);
00357         inline void setVelocityY(const F32 y);
00358         inline void setVelocityZ(const F32 z);
00359         inline void addVelocity(const LLVector3& vel);
00360         inline void setAcceleration(const LLVector3& accel);
00361         inline void setAcceleration(const F32 x, const F32 y, const F32 z);
00362 #else
00363         // Don't override the base LLXForm operators.
00364         // Special case for setPosition.  If not check-for-finite, fall through to LLXform method.
00365         // void         setPosition(F32 x, F32 y, F32 z)
00366         // void         setPosition(LLVector3)
00367 
00368         void            setAngularVelocity(const LLVector3& avel)       { mAngularVelocity = avel; }
00369         void            setAngularVelocity(const F32 x, const F32 y, const F32 z)       { mAngularVelocity.setVec(x,y,z); }
00370         void            setVelocity(const LLVector3& vel)                       { mVelocity = vel; }
00371         void            setVelocity(const F32 x, const F32 y, const F32 z)                      { mVelocity.setVec(x,y,z); }
00372         void            setVelocityX(const F32 x)                                       { mVelocity.mV[VX] = x; }
00373         void            setVelocityY(const F32 y)                                       { mVelocity.mV[VY] = y; }
00374         void            setVelocityZ(const F32 z)                                       { mVelocity.mV[VZ] = z; }
00375         void            addVelocity(const LLVector3& vel)                       { mVelocity += vel; }
00376         void            setAcceleration(const LLVector3& accel)         { mAcceleration = accel; }
00377         void            setAcceleration(const F32 x, const F32 y, const F32 z)          { mAcceleration.setVec(x,y,z); }
00378 #endif
00379         
00380         LLPCode                         getPCode() const                        { return mPrimitiveCode; }
00381         const char *            getPCodeString() const          { return pCodeToString(mPrimitiveCode); }
00382         const LLVector3&        getAngularVelocity() const      { return mAngularVelocity; }
00383         const LLVector3&        getVelocity() const                     { return mVelocity; }
00384         const LLVector3&        getAcceleration() const         { return mAcceleration; }
00385         U8                                      getNumTEs() const                       { return mNumTEs; }
00386 
00387         U8                                      getMaterial() const                     { return mMaterial; }
00388         
00389         void                            setVolumeType(const U8 code);
00390         U8                                      getVolumeType();
00391 
00392         void setTextureList(LLTextureEntry *listp);
00393 
00394         inline BOOL     isAvatar() const;
00395         inline BOOL     isSittingAvatar() const;
00396         inline BOOL     isSittingAvatarOnGround() const;
00397 
00398         void setFlags(U32 flags) { mMiscFlags = flags; }
00399         void addFlags(U32 flags) { mMiscFlags |= flags; }
00400         void removeFlags(U32 flags) { mMiscFlags &= ~flags; }
00401         U32 getFlags() const { return mMiscFlags; }
00402 
00403         static const char *pCodeToString(const LLPCode pcode);
00404         static LLPCode legacyToPCode(const U8 legacy);
00405         static U8 pCodeToLegacy(const LLPCode pcode);
00406         static bool getTESTAxes(const U8 face, U32* s_axis, U32* t_axis);
00407         
00408         inline static BOOL isPrimitive(const LLPCode pcode);
00409         inline static BOOL isApp(const LLPCode pcode);
00410 
00411 protected:
00412         LLPCode                         mPrimitiveCode;         // Primitive code
00413         LLVector3                       mVelocity;                      // how fast are we moving?
00414         LLVector3                       mAcceleration;          // are we under constant acceleration?
00415         LLVector3                       mAngularVelocity;       // angular velocity
00416         LLPointer<LLVolume> mVolumep;
00417         LLTextureEntry          *mTextureList;          // list of texture GUIDs, scales, offsets
00418         U8                                      mMaterial;                      // Material code
00419         U8                                      mNumTEs;                        // # of faces on the primitve   
00420         U32                             mMiscFlags;                     // home for misc bools
00421 
00422         static LLVolumeMgr* sVolumeManager;
00423 };
00424 
00425 inline BOOL LLPrimitive::isAvatar() const
00426 {
00427         return ( LL_PCODE_LEGACY_AVATAR == mPrimitiveCode ) ? TRUE : FALSE;
00428 }
00429 
00430 inline BOOL LLPrimitive::isSittingAvatar() const
00431 {
00432         // this is only used server-side
00433         return ( LL_PCODE_LEGACY_AVATAR == mPrimitiveCode 
00434                          &&      ((getFlags() & (PRIM_FLAG_SITTING | PRIM_FLAG_SITTING_ON_GROUND)) != 0) ) ? TRUE : FALSE;
00435 }
00436 
00437 inline BOOL LLPrimitive::isSittingAvatarOnGround() const
00438 {
00439         // this is only used server-side
00440         return ( LL_PCODE_LEGACY_AVATAR == mPrimitiveCode 
00441                          &&      ((getFlags() & PRIM_FLAG_SITTING_ON_GROUND) != 0) ) ? TRUE : FALSE;
00442 }
00443 
00444 // static
00445 inline BOOL LLPrimitive::isPrimitive(const LLPCode pcode)
00446 {
00447         LLPCode base_type = pcode & LL_PCODE_BASE_MASK;
00448 
00449         if (base_type && (base_type < LL_PCODE_APP))
00450         {
00451                 return TRUE;
00452         }
00453         return FALSE;
00454 }
00455 
00456 // static
00457 inline BOOL LLPrimitive::isApp(const LLPCode pcode)
00458 {
00459         LLPCode base_type = pcode & LL_PCODE_BASE_MASK;
00460 
00461         return (base_type == LL_PCODE_APP);
00462 }
00463 
00464 
00465 #ifdef CHECK_FOR_FINITE
00466 // Special case for setPosition.  If not check-for-finite, fall through to LLXform method.
00467 void LLPrimitive::setPosition(const F32 x, const F32 y, const F32 z)
00468 {
00469         if (llfinite(x) && llfinite(y) && llfinite(z))
00470         {
00471                 LLXform::setPosition(x, y, z);
00472         }
00473         else
00474         {
00475                 llerrs << "Non Finite in LLPrimitive::setPosition(x,y,z) for " << pCodeToString(mPrimitiveCode) << llendl;
00476         }
00477 }
00478 
00479 // Special case for setPosition.  If not check-for-finite, fall through to LLXform method.
00480 void LLPrimitive::setPosition(const LLVector3& pos)
00481 {
00482         if (pos.isFinite())
00483         {
00484                 LLXform::setPosition(pos);
00485         }
00486         else
00487         {
00488                 llerrs << "Non Finite in LLPrimitive::setPosition(LLVector3) for " << pCodeToString(mPrimitiveCode) << llendl;
00489         }
00490 }
00491 
00492 void LLPrimitive::setAngularVelocity(const LLVector3& avel)
00493 { 
00494         if (avel.isFinite())
00495         {
00496                 mAngularVelocity = avel;
00497         }
00498         else
00499         {
00500                 llerror("Non Finite in LLPrimitive::setAngularVelocity", 0);
00501         }
00502 }
00503 
00504 void LLPrimitive::setAngularVelocity(const F32 x, const F32 y, const F32 z)             
00505 { 
00506         if (llfinite(x) && llfinite(y) && llfinite(z))
00507         {
00508                 mAngularVelocity.setVec(x,y,z);
00509         }
00510         else
00511         {
00512                 llerror("Non Finite in LLPrimitive::setAngularVelocity", 0);
00513         }
00514 }
00515 
00516 void LLPrimitive::setVelocity(const LLVector3& vel)                     
00517 { 
00518         if (vel.isFinite())
00519         {
00520                 mVelocity = vel; 
00521         }
00522         else
00523         {
00524                 llerrs << "Non Finite in LLPrimitive::setVelocity(LLVector3) for " << pCodeToString(mPrimitiveCode) << llendl;
00525         }
00526 }
00527 
00528 void LLPrimitive::setVelocity(const F32 x, const F32 y, const F32 z)                    
00529 { 
00530         if (llfinite(x) && llfinite(y) && llfinite(z))
00531         {
00532                 mVelocity.setVec(x,y,z); 
00533         }
00534         else
00535         {
00536                 llerrs << "Non Finite in LLPrimitive::setVelocity(F32,F32,F32) for " << pCodeToString(mPrimitiveCode) << llendl;
00537         }
00538 }
00539 
00540 void LLPrimitive::setVelocityX(const F32 x)                                                     
00541 { 
00542         if (llfinite(x))
00543         {
00544                 mVelocity.mV[VX] = x;
00545         }
00546         else
00547         {
00548                 llerror("Non Finite in LLPrimitive::setVelocityX", 0);
00549         }
00550 }
00551 
00552 void LLPrimitive::setVelocityY(const F32 y)                                                     
00553 { 
00554         if (llfinite(y))
00555         {
00556                 mVelocity.mV[VY] = y;
00557         }
00558         else
00559         {
00560                 llerror("Non Finite in LLPrimitive::setVelocityY", 0);
00561         }
00562 }
00563 
00564 void LLPrimitive::setVelocityZ(const F32 z)                                                     
00565 { 
00566         if (llfinite(z))
00567         {
00568                 mVelocity.mV[VZ] = z;
00569         }
00570         else
00571         {
00572                 llerror("Non Finite in LLPrimitive::setVelocityZ", 0);
00573         }
00574 }
00575 
00576 void LLPrimitive::addVelocity(const LLVector3& vel)                     
00577 { 
00578         if (vel.isFinite())
00579         {
00580                 mVelocity += vel;
00581         }
00582         else
00583         {
00584                 llerror("Non Finite in LLPrimitive::addVelocity", 0);
00585         }
00586 }
00587 
00588 void LLPrimitive::setAcceleration(const LLVector3& accel)               
00589 { 
00590         if (accel.isFinite())
00591         {
00592                 mAcceleration = accel; 
00593         }
00594         else
00595         {
00596                 llerrs << "Non Finite in LLPrimitive::setAcceleration(LLVector3) for " << pCodeToString(mPrimitiveCode) << llendl;
00597         }
00598 }
00599 
00600 void LLPrimitive::setAcceleration(const F32 x, const F32 y, const F32 z)                
00601 { 
00602         if (llfinite(x) && llfinite(y) && llfinite(z))
00603         {
00604                 mAcceleration.setVec(x,y,z); 
00605         }
00606         else
00607         {
00608                 llerrs << "Non Finite in LLPrimitive::setAcceleration(F32,F32,F32) for " << pCodeToString(mPrimitiveCode) << llendl;
00609         }
00610 }
00611 #endif // CHECK_FOR_FINITE
00612 
00613 inline BOOL LLPrimitive::validTE(const U8 te_num) const
00614 {
00615         return (mNumTEs && te_num < mNumTEs);
00616 }
00617 
00618 #endif
00619 

Generated on Fri May 16 08:32:47 2008 for SecondLife by  doxygen 1.5.5