/indra/llprimitive/llprimitive.h

https://bitbucket.org/lindenlab/viewer-beta/ · C Header · 647 lines · 484 code · 90 blank · 73 comment · 29 complexity · fa64ce885e9ae35b1c9f6f2c91aab185 MD5 · raw file

  1. /**
  2. * @file llprimitive.h
  3. * @brief LLPrimitive base class
  4. *
  5. * $LicenseInfo:firstyear=2001&license=viewerlgpl$
  6. * Second Life Viewer Source Code
  7. * Copyright (C) 2010, Linden Research, Inc.
  8. *
  9. * This library is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU Lesser General Public
  11. * License as published by the Free Software Foundation;
  12. * version 2.1 of the License only.
  13. *
  14. * This library is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  17. * Lesser General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU Lesser General Public
  20. * License along with this library; if not, write to the Free Software
  21. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  22. *
  23. * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
  24. * $/LicenseInfo$
  25. */
  26. #ifndef LL_LLPRIMITIVE_H
  27. #define LL_LLPRIMITIVE_H
  28. #include "lluuid.h"
  29. #include "v3math.h"
  30. #include "xform.h"
  31. #include "message.h"
  32. #include "llpointer.h"
  33. #include "llvolume.h"
  34. #include "lltextureentry.h"
  35. #include "llprimtexturelist.h"
  36. // Moved to stdtypes.h --JC
  37. // typedef U8 LLPCode;
  38. class LLMessageSystem;
  39. class LLVolumeParams;
  40. class LLColor4;
  41. class LLColor3;
  42. class LLTextureEntry;
  43. class LLDataPacker;
  44. class LLVolumeMgr;
  45. enum LLGeomType // NOTE: same vals as GL Ids
  46. {
  47. LLInvalid = 0,
  48. LLLineLoop = 2,
  49. LLLineStrip = 3,
  50. LLTriangles = 4,
  51. LLTriStrip = 5,
  52. LLTriFan = 6,
  53. LLQuads = 7,
  54. LLQuadStrip = 8
  55. };
  56. class LLVolume;
  57. /**
  58. * exported constants
  59. */
  60. extern const F32 OBJECT_CUT_MIN;
  61. extern const F32 OBJECT_CUT_MAX;
  62. extern const F32 OBJECT_CUT_INC;
  63. extern const F32 OBJECT_MIN_CUT_INC;
  64. extern const F32 OBJECT_ROTATION_PRECISION;
  65. extern const F32 OBJECT_TWIST_MIN;
  66. extern const F32 OBJECT_TWIST_MAX;
  67. extern const F32 OBJECT_TWIST_INC;
  68. // This is used for linear paths,
  69. // since twist is used in a slightly different manner.
  70. extern const F32 OBJECT_TWIST_LINEAR_MIN;
  71. extern const F32 OBJECT_TWIST_LINEAR_MAX;
  72. extern const F32 OBJECT_TWIST_LINEAR_INC;
  73. extern const F32 OBJECT_MIN_HOLE_SIZE;
  74. extern const F32 OBJECT_MAX_HOLE_SIZE_X;
  75. extern const F32 OBJECT_MAX_HOLE_SIZE_Y;
  76. // Revolutions parameters.
  77. extern const F32 OBJECT_REV_MIN;
  78. extern const F32 OBJECT_REV_MAX;
  79. extern const F32 OBJECT_REV_INC;
  80. extern const char *SCULPT_DEFAULT_TEXTURE;
  81. //============================================================================
  82. // TomY: Base class for things that pack & unpack themselves
  83. class LLNetworkData
  84. {
  85. public:
  86. // Extra parameter IDs
  87. enum
  88. {
  89. PARAMS_FLEXIBLE = 0x10,
  90. PARAMS_LIGHT = 0x20,
  91. PARAMS_SCULPT = 0x30,
  92. PARAMS_LIGHT_IMAGE = 0x40,
  93. PARAMS_RESERVED = 0x50, // Used on server-side
  94. PARAMS_MESH = 0x60,
  95. };
  96. public:
  97. U16 mType;
  98. virtual ~LLNetworkData() {};
  99. virtual BOOL pack(LLDataPacker &dp) const = 0;
  100. virtual BOOL unpack(LLDataPacker &dp) = 0;
  101. virtual bool operator==(const LLNetworkData& data) const = 0;
  102. virtual void copy(const LLNetworkData& data) = 0;
  103. static BOOL isValid(U16 param_type, U32 size);
  104. };
  105. extern const F32 LIGHT_MIN_RADIUS;
  106. extern const F32 LIGHT_DEFAULT_RADIUS;
  107. extern const F32 LIGHT_MAX_RADIUS;
  108. extern const F32 LIGHT_MIN_FALLOFF;
  109. extern const F32 LIGHT_DEFAULT_FALLOFF;
  110. extern const F32 LIGHT_MAX_FALLOFF;
  111. extern const F32 LIGHT_MIN_CUTOFF;
  112. extern const F32 LIGHT_DEFAULT_CUTOFF;
  113. extern const F32 LIGHT_MAX_CUTOFF;
  114. class LLLightParams : public LLNetworkData
  115. {
  116. protected:
  117. LLColor4 mColor; // alpha = intensity
  118. F32 mRadius;
  119. F32 mFalloff;
  120. F32 mCutoff;
  121. public:
  122. LLLightParams();
  123. /*virtual*/ BOOL pack(LLDataPacker &dp) const;
  124. /*virtual*/ BOOL unpack(LLDataPacker &dp);
  125. /*virtual*/ bool operator==(const LLNetworkData& data) const;
  126. /*virtual*/ void copy(const LLNetworkData& data);
  127. // LLSD implementations here are provided by Eddy Stryker.
  128. // NOTE: there are currently unused in protocols
  129. LLSD asLLSD() const;
  130. operator LLSD() const { return asLLSD(); }
  131. bool fromLLSD(LLSD& sd);
  132. void setColor(const LLColor4& color) { mColor = color; mColor.clamp(); }
  133. void setRadius(F32 radius) { mRadius = llclamp(radius, LIGHT_MIN_RADIUS, LIGHT_MAX_RADIUS); }
  134. void setFalloff(F32 falloff) { mFalloff = llclamp(falloff, LIGHT_MIN_FALLOFF, LIGHT_MAX_FALLOFF); }
  135. void setCutoff(F32 cutoff) { mCutoff = llclamp(cutoff, LIGHT_MIN_CUTOFF, LIGHT_MAX_CUTOFF); }
  136. LLColor4 getColor() const { return mColor; }
  137. F32 getRadius() const { return mRadius; }
  138. F32 getFalloff() const { return mFalloff; }
  139. F32 getCutoff() const { return mCutoff; }
  140. };
  141. //-------------------------------------------------
  142. // This structure is also used in the part of the
  143. // code that creates new flexible objects.
  144. //-------------------------------------------------
  145. // These were made into enums so that they could be used as fixed size
  146. // array bounds.
  147. enum EFlexibleObjectConst
  148. {
  149. // "Softness" => [0,3], increments of 1
  150. // Represents powers of 2: 0 -> 1, 3 -> 8
  151. FLEXIBLE_OBJECT_MIN_SECTIONS = 0,
  152. FLEXIBLE_OBJECT_DEFAULT_NUM_SECTIONS = 2,
  153. FLEXIBLE_OBJECT_MAX_SECTIONS = 3
  154. };
  155. // "Tension" => [0,10], increments of 0.1
  156. extern const F32 FLEXIBLE_OBJECT_MIN_TENSION;
  157. extern const F32 FLEXIBLE_OBJECT_DEFAULT_TENSION;
  158. extern const F32 FLEXIBLE_OBJECT_MAX_TENSION;
  159. // "Drag" => [0,10], increments of 0.1
  160. extern const F32 FLEXIBLE_OBJECT_MIN_AIR_FRICTION;
  161. extern const F32 FLEXIBLE_OBJECT_DEFAULT_AIR_FRICTION;
  162. extern const F32 FLEXIBLE_OBJECT_MAX_AIR_FRICTION;
  163. // "Gravity" = [-10,10], increments of 0.1
  164. extern const F32 FLEXIBLE_OBJECT_MIN_GRAVITY;
  165. extern const F32 FLEXIBLE_OBJECT_DEFAULT_GRAVITY;
  166. extern const F32 FLEXIBLE_OBJECT_MAX_GRAVITY;
  167. // "Wind" = [0,10], increments of 0.1
  168. extern const F32 FLEXIBLE_OBJECT_MIN_WIND_SENSITIVITY;
  169. extern const F32 FLEXIBLE_OBJECT_DEFAULT_WIND_SENSITIVITY;
  170. extern const F32 FLEXIBLE_OBJECT_MAX_WIND_SENSITIVITY;
  171. extern const F32 FLEXIBLE_OBJECT_MAX_INTERNAL_TENSION_FORCE;
  172. extern const F32 FLEXIBLE_OBJECT_DEFAULT_LENGTH;
  173. extern const BOOL FLEXIBLE_OBJECT_DEFAULT_USING_COLLISION_SPHERE;
  174. extern const BOOL FLEXIBLE_OBJECT_DEFAULT_RENDERING_COLLISION_SPHERE;
  175. class LLFlexibleObjectData : public LLNetworkData
  176. {
  177. protected:
  178. S32 mSimulateLOD; // 2^n = number of simulated sections
  179. F32 mGravity;
  180. F32 mAirFriction; // higher is more stable, but too much looks like it's underwater
  181. F32 mWindSensitivity; // interacts with tension, air friction, and gravity
  182. F32 mTension; //interacts in complex ways with other parameters
  183. LLVector3 mUserForce; // custom user-defined force vector
  184. //BOOL mUsingCollisionSphere;
  185. //BOOL mRenderingCollisionSphere;
  186. public:
  187. void setSimulateLOD(S32 lod) { mSimulateLOD = llclamp(lod, (S32)FLEXIBLE_OBJECT_MIN_SECTIONS, (S32)FLEXIBLE_OBJECT_MAX_SECTIONS); }
  188. void setGravity(F32 gravity) { mGravity = llclamp(gravity, FLEXIBLE_OBJECT_MIN_GRAVITY, FLEXIBLE_OBJECT_MAX_GRAVITY); }
  189. void setAirFriction(F32 friction) { mAirFriction = llclamp(friction, FLEXIBLE_OBJECT_MIN_AIR_FRICTION, FLEXIBLE_OBJECT_MAX_AIR_FRICTION); }
  190. void setWindSensitivity(F32 wind) { mWindSensitivity = llclamp(wind, FLEXIBLE_OBJECT_MIN_WIND_SENSITIVITY, FLEXIBLE_OBJECT_MAX_WIND_SENSITIVITY); }
  191. void setTension(F32 tension) { mTension = llclamp(tension, FLEXIBLE_OBJECT_MIN_TENSION, FLEXIBLE_OBJECT_MAX_TENSION); }
  192. void setUserForce(LLVector3 &force) { mUserForce = force; }
  193. S32 getSimulateLOD() const { return mSimulateLOD; }
  194. F32 getGravity() const { return mGravity; }
  195. F32 getAirFriction() const { return mAirFriction; }
  196. F32 getWindSensitivity() const { return mWindSensitivity; }
  197. F32 getTension() const { return mTension; }
  198. LLVector3 getUserForce() const { return mUserForce; }
  199. //------ the constructor for the structure ------------
  200. LLFlexibleObjectData();
  201. BOOL pack(LLDataPacker &dp) const;
  202. BOOL unpack(LLDataPacker &dp);
  203. bool operator==(const LLNetworkData& data) const;
  204. void copy(const LLNetworkData& data);
  205. LLSD asLLSD() const;
  206. operator LLSD() const { return asLLSD(); }
  207. bool fromLLSD(LLSD& sd);
  208. };// end of attributes structure
  209. class LLSculptParams : public LLNetworkData
  210. {
  211. protected:
  212. LLUUID mSculptTexture;
  213. U8 mSculptType;
  214. public:
  215. LLSculptParams();
  216. /*virtual*/ BOOL pack(LLDataPacker &dp) const;
  217. /*virtual*/ BOOL unpack(LLDataPacker &dp);
  218. /*virtual*/ bool operator==(const LLNetworkData& data) const;
  219. /*virtual*/ void copy(const LLNetworkData& data);
  220. LLSD asLLSD() const;
  221. operator LLSD() const { return asLLSD(); }
  222. bool fromLLSD(LLSD& sd);
  223. void setSculptTexture(const LLUUID& id) { mSculptTexture = id; }
  224. LLUUID getSculptTexture() const { return mSculptTexture; }
  225. void setSculptType(U8 type) { mSculptType = type; }
  226. U8 getSculptType() const { return mSculptType; }
  227. };
  228. class LLLightImageParams : public LLNetworkData
  229. {
  230. protected:
  231. LLUUID mLightTexture;
  232. LLVector3 mParams;
  233. public:
  234. LLLightImageParams();
  235. /*virtual*/ BOOL pack(LLDataPacker &dp) const;
  236. /*virtual*/ BOOL unpack(LLDataPacker &dp);
  237. /*virtual*/ bool operator==(const LLNetworkData& data) const;
  238. /*virtual*/ void copy(const LLNetworkData& data);
  239. LLSD asLLSD() const;
  240. operator LLSD() const { return asLLSD(); }
  241. bool fromLLSD(LLSD& sd);
  242. void setLightTexture(const LLUUID& id) { mLightTexture = id; }
  243. LLUUID getLightTexture() const { return mLightTexture; }
  244. bool isLightSpotlight() const { return mLightTexture.notNull(); }
  245. void setParams(const LLVector3& params) { mParams = params; }
  246. LLVector3 getParams() const { return mParams; }
  247. };
  248. class LLPrimitive : public LLXform
  249. {
  250. public:
  251. // HACK for removing LLPrimitive's dependency on gVolumeMgr global.
  252. // If a different LLVolumeManager is instantiated and set early enough
  253. // then the LLPrimitive class will use it instead of gVolumeMgr.
  254. static LLVolumeMgr* getVolumeManager() { return sVolumeManager; }
  255. static void setVolumeManager( LLVolumeMgr* volume_manager);
  256. static bool cleanupVolumeManager();
  257. // these flags influence how the RigidBody representation is built
  258. static const U32 PRIM_FLAG_PHANTOM = 0x1 << 0;
  259. static const U32 PRIM_FLAG_VOLUME_DETECT = 0x1 << 1;
  260. static const U32 PRIM_FLAG_DYNAMIC = 0x1 << 2;
  261. static const U32 PRIM_FLAG_AVATAR = 0x1 << 3;
  262. static const U32 PRIM_FLAG_SCULPT = 0x1 << 4;
  263. // not used yet, but soon
  264. static const U32 PRIM_FLAG_COLLISION_CALLBACK = 0x1 << 5;
  265. static const U32 PRIM_FLAG_CONVEX = 0x1 << 6;
  266. static const U32 PRIM_FLAG_DEFAULT_VOLUME = 0x1 << 7;
  267. static const U32 PRIM_FLAG_SITTING = 0x1 << 8;
  268. static const U32 PRIM_FLAG_SITTING_ON_GROUND = 0x1 << 9; // Set along with PRIM_FLAG_SITTING
  269. LLPrimitive();
  270. virtual ~LLPrimitive();
  271. void clearTextureList();
  272. static LLPrimitive *createPrimitive(LLPCode p_code);
  273. void init_primitive(LLPCode p_code);
  274. void setPCode(const LLPCode pcode);
  275. const LLVolume *getVolumeConst() const { return mVolumep; } // HACK for Windoze confusion about ostream operator in LLVolume
  276. LLVolume *getVolume() const { return mVolumep; }
  277. virtual BOOL setVolume(const LLVolumeParams &volume_params, const S32 detail, bool unique_volume = false);
  278. // Modify texture entry properties
  279. inline BOOL validTE(const U8 te_num) const;
  280. LLTextureEntry* getTE(const U8 te_num) const;
  281. virtual void setNumTEs(const U8 num_tes);
  282. virtual void setAllTETextures(const LLUUID &tex_id);
  283. virtual void setTE(const U8 index, const LLTextureEntry& te);
  284. virtual S32 setTEColor(const U8 te, const LLColor4 &color);
  285. virtual S32 setTEColor(const U8 te, const LLColor3 &color);
  286. virtual S32 setTEAlpha(const U8 te, const F32 alpha);
  287. virtual S32 setTETexture(const U8 te, const LLUUID &tex_id);
  288. virtual S32 setTEScale (const U8 te, const F32 s, const F32 t);
  289. virtual S32 setTEScaleS(const U8 te, const F32 s);
  290. virtual S32 setTEScaleT(const U8 te, const F32 t);
  291. virtual S32 setTEOffset (const U8 te, const F32 s, const F32 t);
  292. virtual S32 setTEOffsetS(const U8 te, const F32 s);
  293. virtual S32 setTEOffsetT(const U8 te, const F32 t);
  294. virtual S32 setTERotation(const U8 te, const F32 r);
  295. virtual S32 setTEBumpShinyFullbright(const U8 te, const U8 bump);
  296. virtual S32 setTEBumpShiny(const U8 te, const U8 bump);
  297. virtual S32 setTEMediaTexGen(const U8 te, const U8 media);
  298. virtual S32 setTEBumpmap(const U8 te, const U8 bump);
  299. virtual S32 setTETexGen(const U8 te, const U8 texgen);
  300. virtual S32 setTEShiny(const U8 te, const U8 shiny);
  301. virtual S32 setTEFullbright(const U8 te, const U8 fullbright);
  302. virtual S32 setTEMediaFlags(const U8 te, const U8 flags);
  303. virtual S32 setTEGlow(const U8 te, const F32 glow);
  304. virtual BOOL setMaterial(const U8 material); // returns TRUE if material changed
  305. void copyTEs(const LLPrimitive *primitive);
  306. S32 packTEField(U8 *cur_ptr, U8 *data_ptr, U8 data_size, U8 last_face_index, EMsgVariableType type) const;
  307. S32 unpackTEField(U8 *cur_ptr, U8 *buffer_end, U8 *data_ptr, U8 data_size, U8 face_count, EMsgVariableType type);
  308. BOOL packTEMessage(LLMessageSystem *mesgsys) const;
  309. BOOL packTEMessage(LLDataPacker &dp) const;
  310. S32 unpackTEMessage(LLMessageSystem* mesgsys, char const* block_name);
  311. S32 unpackTEMessage(LLMessageSystem* mesgsys, char const* block_name, const S32 block_num); // Variable num of blocks
  312. BOOL unpackTEMessage(LLDataPacker &dp);
  313. #ifdef CHECK_FOR_FINITE
  314. inline void setPosition(const LLVector3& pos);
  315. inline void setPosition(const F32 x, const F32 y, const F32 z);
  316. inline void addPosition(const LLVector3& pos);
  317. inline void setAngularVelocity(const LLVector3& avel);
  318. inline void setAngularVelocity(const F32 x, const F32 y, const F32 z);
  319. inline void setVelocity(const LLVector3& vel);
  320. inline void setVelocity(const F32 x, const F32 y, const F32 z);
  321. inline void setVelocityX(const F32 x);
  322. inline void setVelocityY(const F32 y);
  323. inline void setVelocityZ(const F32 z);
  324. inline void addVelocity(const LLVector3& vel);
  325. inline void setAcceleration(const LLVector3& accel);
  326. inline void setAcceleration(const F32 x, const F32 y, const F32 z);
  327. #else
  328. // Don't override the base LLXForm operators.
  329. // Special case for setPosition. If not check-for-finite, fall through to LLXform method.
  330. // void setPosition(F32 x, F32 y, F32 z)
  331. // void setPosition(LLVector3)
  332. void setAngularVelocity(const LLVector3& avel) { mAngularVelocity = avel; }
  333. void setAngularVelocity(const F32 x, const F32 y, const F32 z) { mAngularVelocity.setVec(x,y,z); }
  334. void setVelocity(const LLVector3& vel) { mVelocity = vel; }
  335. void setVelocity(const F32 x, const F32 y, const F32 z) { mVelocity.setVec(x,y,z); }
  336. void setVelocityX(const F32 x) { mVelocity.mV[VX] = x; }
  337. void setVelocityY(const F32 y) { mVelocity.mV[VY] = y; }
  338. void setVelocityZ(const F32 z) { mVelocity.mV[VZ] = z; }
  339. void addVelocity(const LLVector3& vel) { mVelocity += vel; }
  340. void setAcceleration(const LLVector3& accel) { mAcceleration = accel; }
  341. void setAcceleration(const F32 x, const F32 y, const F32 z) { mAcceleration.setVec(x,y,z); }
  342. #endif
  343. LLPCode getPCode() const { return mPrimitiveCode; }
  344. std::string getPCodeString() const { return pCodeToString(mPrimitiveCode); }
  345. const LLVector3& getAngularVelocity() const { return mAngularVelocity; }
  346. const LLVector3& getVelocity() const { return mVelocity; }
  347. const LLVector3& getAcceleration() const { return mAcceleration; }
  348. U8 getNumTEs() const { return mTextureList.size(); }
  349. U8 getExpectedNumTEs() const;
  350. U8 getMaterial() const { return mMaterial; }
  351. void setVolumeType(const U8 code);
  352. U8 getVolumeType();
  353. // clears existing textures
  354. // copies the contents of other_list into mEntryList
  355. void copyTextureList(const LLPrimTextureList& other_list);
  356. // clears existing textures
  357. // takes the contents of other_list and clears other_list
  358. void takeTextureList(LLPrimTextureList& other_list);
  359. inline BOOL isAvatar() const;
  360. inline BOOL isSittingAvatar() const;
  361. inline BOOL isSittingAvatarOnGround() const;
  362. void setFlags(U32 flags) { mMiscFlags = flags; }
  363. void addFlags(U32 flags) { mMiscFlags |= flags; }
  364. void removeFlags(U32 flags) { mMiscFlags &= ~flags; }
  365. U32 getFlags() const { return mMiscFlags; }
  366. static std::string pCodeToString(const LLPCode pcode);
  367. static LLPCode legacyToPCode(const U8 legacy);
  368. static U8 pCodeToLegacy(const LLPCode pcode);
  369. static bool getTESTAxes(const U8 face, U32* s_axis, U32* t_axis);
  370. inline static BOOL isPrimitive(const LLPCode pcode);
  371. inline static BOOL isApp(const LLPCode pcode);
  372. protected:
  373. LLPCode mPrimitiveCode; // Primitive code
  374. LLVector3 mVelocity; // how fast are we moving?
  375. LLVector3 mAcceleration; // are we under constant acceleration?
  376. LLVector3 mAngularVelocity; // angular velocity
  377. LLPointer<LLVolume> mVolumep;
  378. LLPrimTextureList mTextureList; // list of texture GUIDs, scales, offsets
  379. U8 mMaterial; // Material code
  380. U8 mNumTEs; // # of faces on the primitve
  381. U32 mMiscFlags; // home for misc bools
  382. public:
  383. static LLVolumeMgr* sVolumeManager;
  384. };
  385. inline BOOL LLPrimitive::isAvatar() const
  386. {
  387. return ( LL_PCODE_LEGACY_AVATAR == mPrimitiveCode ) ? TRUE : FALSE;
  388. }
  389. inline BOOL LLPrimitive::isSittingAvatar() const
  390. {
  391. // this is only used server-side
  392. return ( LL_PCODE_LEGACY_AVATAR == mPrimitiveCode
  393. && ((getFlags() & (PRIM_FLAG_SITTING | PRIM_FLAG_SITTING_ON_GROUND)) != 0) ) ? TRUE : FALSE;
  394. }
  395. inline BOOL LLPrimitive::isSittingAvatarOnGround() const
  396. {
  397. // this is only used server-side
  398. return ( LL_PCODE_LEGACY_AVATAR == mPrimitiveCode
  399. && ((getFlags() & PRIM_FLAG_SITTING_ON_GROUND) != 0) ) ? TRUE : FALSE;
  400. }
  401. // static
  402. inline BOOL LLPrimitive::isPrimitive(const LLPCode pcode)
  403. {
  404. LLPCode base_type = pcode & LL_PCODE_BASE_MASK;
  405. if (base_type && (base_type < LL_PCODE_APP))
  406. {
  407. return TRUE;
  408. }
  409. return FALSE;
  410. }
  411. // static
  412. inline BOOL LLPrimitive::isApp(const LLPCode pcode)
  413. {
  414. LLPCode base_type = pcode & LL_PCODE_BASE_MASK;
  415. return (base_type == LL_PCODE_APP);
  416. }
  417. #ifdef CHECK_FOR_FINITE
  418. // Special case for setPosition. If not check-for-finite, fall through to LLXform method.
  419. void LLPrimitive::setPosition(const F32 x, const F32 y, const F32 z)
  420. {
  421. if (llfinite(x) && llfinite(y) && llfinite(z))
  422. {
  423. LLXform::setPosition(x, y, z);
  424. }
  425. else
  426. {
  427. llerrs << "Non Finite in LLPrimitive::setPosition(x,y,z) for " << pCodeToString(mPrimitiveCode) << llendl;
  428. }
  429. }
  430. // Special case for setPosition. If not check-for-finite, fall through to LLXform method.
  431. void LLPrimitive::setPosition(const LLVector3& pos)
  432. {
  433. if (pos.isFinite())
  434. {
  435. LLXform::setPosition(pos);
  436. }
  437. else
  438. {
  439. llerrs << "Non Finite in LLPrimitive::setPosition(LLVector3) for " << pCodeToString(mPrimitiveCode) << llendl;
  440. }
  441. }
  442. void LLPrimitive::setAngularVelocity(const LLVector3& avel)
  443. {
  444. if (avel.isFinite())
  445. {
  446. mAngularVelocity = avel;
  447. }
  448. else
  449. {
  450. llerror("Non Finite in LLPrimitive::setAngularVelocity", 0);
  451. }
  452. }
  453. void LLPrimitive::setAngularVelocity(const F32 x, const F32 y, const F32 z)
  454. {
  455. if (llfinite(x) && llfinite(y) && llfinite(z))
  456. {
  457. mAngularVelocity.setVec(x,y,z);
  458. }
  459. else
  460. {
  461. llerror("Non Finite in LLPrimitive::setAngularVelocity", 0);
  462. }
  463. }
  464. void LLPrimitive::setVelocity(const LLVector3& vel)
  465. {
  466. if (vel.isFinite())
  467. {
  468. mVelocity = vel;
  469. }
  470. else
  471. {
  472. llerrs << "Non Finite in LLPrimitive::setVelocity(LLVector3) for " << pCodeToString(mPrimitiveCode) << llendl;
  473. }
  474. }
  475. void LLPrimitive::setVelocity(const F32 x, const F32 y, const F32 z)
  476. {
  477. if (llfinite(x) && llfinite(y) && llfinite(z))
  478. {
  479. mVelocity.setVec(x,y,z);
  480. }
  481. else
  482. {
  483. llerrs << "Non Finite in LLPrimitive::setVelocity(F32,F32,F32) for " << pCodeToString(mPrimitiveCode) << llendl;
  484. }
  485. }
  486. void LLPrimitive::setVelocityX(const F32 x)
  487. {
  488. if (llfinite(x))
  489. {
  490. mVelocity.mV[VX] = x;
  491. }
  492. else
  493. {
  494. llerror("Non Finite in LLPrimitive::setVelocityX", 0);
  495. }
  496. }
  497. void LLPrimitive::setVelocityY(const F32 y)
  498. {
  499. if (llfinite(y))
  500. {
  501. mVelocity.mV[VY] = y;
  502. }
  503. else
  504. {
  505. llerror("Non Finite in LLPrimitive::setVelocityY", 0);
  506. }
  507. }
  508. void LLPrimitive::setVelocityZ(const F32 z)
  509. {
  510. if (llfinite(z))
  511. {
  512. mVelocity.mV[VZ] = z;
  513. }
  514. else
  515. {
  516. llerror("Non Finite in LLPrimitive::setVelocityZ", 0);
  517. }
  518. }
  519. void LLPrimitive::addVelocity(const LLVector3& vel)
  520. {
  521. if (vel.isFinite())
  522. {
  523. mVelocity += vel;
  524. }
  525. else
  526. {
  527. llerror("Non Finite in LLPrimitive::addVelocity", 0);
  528. }
  529. }
  530. void LLPrimitive::setAcceleration(const LLVector3& accel)
  531. {
  532. if (accel.isFinite())
  533. {
  534. mAcceleration = accel;
  535. }
  536. else
  537. {
  538. llerrs << "Non Finite in LLPrimitive::setAcceleration(LLVector3) for " << pCodeToString(mPrimitiveCode) << llendl;
  539. }
  540. }
  541. void LLPrimitive::setAcceleration(const F32 x, const F32 y, const F32 z)
  542. {
  543. if (llfinite(x) && llfinite(y) && llfinite(z))
  544. {
  545. mAcceleration.setVec(x,y,z);
  546. }
  547. else
  548. {
  549. llerrs << "Non Finite in LLPrimitive::setAcceleration(F32,F32,F32) for " << pCodeToString(mPrimitiveCode) << llendl;
  550. }
  551. }
  552. #endif // CHECK_FOR_FINITE
  553. inline BOOL LLPrimitive::validTE(const U8 te_num) const
  554. {
  555. return (mNumTEs && te_num < mNumTEs);
  556. }
  557. #endif