llprimitive.h 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617
  1. /**
  2. * @file llprimitive.h
  3. * @brief LLPrimitive base class
  4. *
  5. * $LicenseInfo:firstyear=2001&license=viewergpl$
  6. *
  7. * Copyright (c) 2001-2009, Linden Research, Inc.
  8. *
  9. * Second Life Viewer Source Code
  10. * The source code in this file ("Source Code") is provided by Linden Lab
  11. * to you under the terms of the GNU General Public License, version 2.0
  12. * ("GPL"), unless you have obtained a separate licensing agreement
  13. * ("Other License"), formally executed by you and Linden Lab. Terms of
  14. * the GPL can be found in doc/GPL-license.txt in this distribution, or
  15. * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
  16. *
  17. * There are special exceptions to the terms and conditions of the GPL as
  18. * it is applied to this Source Code. View the full text of the exception
  19. * in the file doc/FLOSS-exception.txt in this software distribution, or
  20. * online at
  21. * http://secondlifegrid.net/programs/open_source/licensing/flossexception
  22. *
  23. * By copying, modifying or distributing this software, you acknowledge
  24. * that you have read and understood your obligations described above,
  25. * and agree to abide by those obligations.
  26. *
  27. * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
  28. * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
  29. * COMPLETENESS OR PERFORMANCE.
  30. * $/LicenseInfo$
  31. */
  32. #ifndef LL_LLPRIMITIVE_H
  33. #define LL_LLPRIMITIVE_H
  34. #include "llprimtexturelist.h"
  35. #include "lltextureentry.h"
  36. #include "llmessage.h"
  37. #include "llxform.h"
  38. #include "indra_constants.h"
  39. #define MAX_TES 45U
  40. #define MAX_TE_BUFFER 4096U
  41. class LLColor3;
  42. class LLColor4U;
  43. class LLDataPacker;
  44. class LLMessageSystem;
  45. class LLTextureEntry;
  46. class LLVolumeParams;
  47. enum LLGeomType // Note: same values as GL Ids
  48. {
  49. LLInvalid = 0,
  50. LLLineLoop = 2,
  51. LLLineStrip = 3,
  52. LLTriangles = 4,
  53. LLTriStrip = 5,
  54. LLTriFan = 6,
  55. LLQuads = 7,
  56. LLQuadStrip = 8
  57. };
  58. // Old inverted texture: "7595d345-a24c-e7ef-f0bd-78793792133e";
  59. extern const char* SCULPT_DEFAULT_TEXTURE;
  60. // Texture rotations are sent over the wire as a S16. This is used to scale the
  61. // actual float value to a S16. Do not use 7FFF as it introduces some odd
  62. // rounding with 180 since it can't be divided by 2. See DEV-19108
  63. constexpr F32 TEXTURE_ROTATION_PACK_FACTOR = ((F32)0x08000);
  64. //============================================================================
  65. // Macros used (in llviewerobject.cpp only, but keeping the macros here in case
  66. // the extra params enum is modified in the future) to transform a parameter
  67. // type into an index (starting from 0) in a vector/array, and vice versa.
  68. // This works because LLNetworkData::PARAMS_* below are a series starting from
  69. // 0x10 with a 0x10 increment. Should this change, these macros should change !
  70. #define LL_EPARAM_INDEX(param_type) ((param_type >> 4) - 1)
  71. #define LL_EPARAM_TYPE(index) ((index + 1) << 4)
  72. // Number of LLNetworkData::PARAMS_* entries in the enum below
  73. #define LL_EPARAMS_COUNT 9
  74. // TomY: base class for things that pack & unpack themselves
  75. class LLNetworkData
  76. {
  77. public:
  78. // Extra parameter IDs
  79. enum
  80. {
  81. PARAMS_FLEXIBLE = 0x10,
  82. PARAMS_LIGHT = 0x20,
  83. PARAMS_SCULPT = 0x30,
  84. PARAMS_LIGHT_IMAGE = 0x40,
  85. PARAMS_RESERVED = 0x50, // Used on server-side
  86. PARAMS_MESH = 0x60,
  87. PARAMS_EXTENDED_MESH = 0x70,
  88. PARAMS_RENDER_MATERIAL = 0x80,
  89. PARAMS_REFLECTION_PROBE = 0x90,
  90. };
  91. virtual ~LLNetworkData() {}
  92. virtual bool pack(LLDataPacker& dp) const = 0;
  93. virtual bool unpack(LLDataPacker& dp) = 0;
  94. virtual bool operator==(const LLNetworkData& data) const = 0;
  95. virtual void copy(const LLNetworkData& data) = 0;
  96. static bool isValid(U16 param_type, U32 size);
  97. public:
  98. U16 mType;
  99. };
  100. class LLLightParams : public LLNetworkData
  101. {
  102. public:
  103. LLLightParams();
  104. bool pack(LLDataPacker& dp) const override;
  105. bool unpack(LLDataPacker& dp) override;
  106. bool operator==(const LLNetworkData& data) const override;
  107. void copy(const LLNetworkData& data) override;
  108. // LLSD implementations here are provided by Eddy Stryker.
  109. // NOTE: there are currently unused in protocols
  110. LLSD asLLSD() const;
  111. LL_INLINE operator LLSD() const { return asLLSD(); }
  112. bool fromLLSD(LLSD& sd);
  113. LL_INLINE void setLinearColor(const LLColor4& color)
  114. {
  115. mColor = color;
  116. mColor.clamp();
  117. }
  118. LL_INLINE void setSRGBColor(const LLColor4& color) { setLinearColor(linearColor4(color)); }
  119. LL_INLINE void setRadius(F32 radius) { mRadius = llclamp(radius, LIGHT_MIN_RADIUS, LIGHT_MAX_RADIUS); }
  120. LL_INLINE void setFalloff(F32 falloff) { mFalloff = llclamp(falloff, LIGHT_MIN_FALLOFF, LIGHT_MAX_FALLOFF); }
  121. LL_INLINE void setCutoff(F32 cutoff) { mCutoff = llclamp(cutoff, LIGHT_MIN_CUTOFF, LIGHT_MAX_CUTOFF); }
  122. LL_INLINE LLColor4 getLinearColor() const { return mColor; }
  123. LL_INLINE LLColor4 getSRGBColor() const { return srgbColor4(mColor); }
  124. LL_INLINE F32 getRadius() const { return mRadius; }
  125. LL_INLINE F32 getFalloff() const { return mFalloff; }
  126. LL_INLINE F32 getCutoff() const { return mCutoff; }
  127. private:
  128. // Linear color (not gamma corrected), with alpha = intensity
  129. LLColor4 mColor;
  130. F32 mRadius;
  131. F32 mFalloff;
  132. F32 mCutoff;
  133. };
  134. // These were made into enums so that they could be used as fixed size array
  135. // bounds.
  136. enum EFlexibleObjectConst
  137. {
  138. // "Softness" => [0,3], increments of 1
  139. // Represents powers of 2: 0 -> 1, 3 -> 8
  140. FLEXIBLE_OBJECT_MIN_SECTIONS = 0,
  141. FLEXIBLE_OBJECT_DEFAULT_NUM_SECTIONS = 2,
  142. FLEXIBLE_OBJECT_MAX_SECTIONS = 3
  143. };
  144. class LLFlexibleObjectData : public LLNetworkData
  145. {
  146. public:
  147. LLFlexibleObjectData();
  148. LL_INLINE void setSimulateLOD(S32 lod) { mSimulateLOD = llclamp(lod, (S32)FLEXIBLE_OBJECT_MIN_SECTIONS, (S32)FLEXIBLE_OBJECT_MAX_SECTIONS); }
  149. LL_INLINE void setGravity(F32 gravity) { mGravity = llclamp(gravity, FLEXIBLE_OBJECT_MIN_GRAVITY, FLEXIBLE_OBJECT_MAX_GRAVITY); }
  150. LL_INLINE void setAirFriction(F32 friction) { mAirFriction = llclamp(friction, FLEXIBLE_OBJECT_MIN_AIR_FRICTION, FLEXIBLE_OBJECT_MAX_AIR_FRICTION); }
  151. LL_INLINE void setWindSensitivity(F32 wind) { mWindSensitivity = llclamp(wind, FLEXIBLE_OBJECT_MIN_WIND_SENSITIVITY, FLEXIBLE_OBJECT_MAX_WIND_SENSITIVITY); }
  152. LL_INLINE void setTension(F32 tension) { mTension = llclamp(tension, FLEXIBLE_OBJECT_MIN_TENSION, FLEXIBLE_OBJECT_MAX_TENSION); }
  153. LL_INLINE void setUserForce(LLVector3& force) { mUserForce = force; }
  154. LL_INLINE S32 getSimulateLOD() const { return mSimulateLOD; }
  155. LL_INLINE F32 getGravity() const { return mGravity; }
  156. LL_INLINE F32 getAirFriction() const { return mAirFriction; }
  157. LL_INLINE F32 getWindSensitivity() const { return mWindSensitivity; }
  158. LL_INLINE F32 getTension() const { return mTension; }
  159. LL_INLINE LLVector3 getUserForce() const { return mUserForce; }
  160. bool pack(LLDataPacker& dp) const;
  161. bool unpack(LLDataPacker& dp);
  162. bool operator==(const LLNetworkData& data) const;
  163. void copy(const LLNetworkData& data);
  164. LLSD asLLSD() const;
  165. LL_INLINE operator LLSD() const { return asLLSD(); }
  166. bool fromLLSD(LLSD& sd);
  167. protected:
  168. S32 mSimulateLOD; // 2^n = number of simulated sections
  169. F32 mGravity;
  170. F32 mAirFriction; // higher is more stable, but too much looks like it's underwater
  171. F32 mWindSensitivity; // interacts with tension, air friction, and gravity
  172. F32 mTension; // interacts in complex ways with other parameters
  173. LLVector3 mUserForce; // custom user-defined force vector
  174. #if 0
  175. bool mUsingCollisionSphere;
  176. bool mRenderingCollisionSphere;
  177. #endif
  178. };
  179. class LLSculptParams : public LLNetworkData
  180. {
  181. public:
  182. LLSculptParams();
  183. bool pack(LLDataPacker& dp) const override;
  184. bool unpack(LLDataPacker& dp) override;
  185. bool operator==(const LLNetworkData& data) const override;
  186. void copy(const LLNetworkData& data) override;
  187. LLSD asLLSD() const;
  188. LL_INLINE operator LLSD() const { return asLLSD(); }
  189. bool fromLLSD(LLSD& sd);
  190. void setSculptTexture(const LLUUID& id, U8 sculpt_type);
  191. LL_INLINE const LLUUID& getSculptTexture() const { return mSculptTexture; }
  192. LL_INLINE U8 getSculptType() const { return mSculptType; }
  193. protected:
  194. LLUUID mSculptTexture;
  195. U8 mSculptType;
  196. };
  197. class LLLightImageParams : public LLNetworkData
  198. {
  199. public:
  200. LLLightImageParams();
  201. bool pack(LLDataPacker& dp) const override;
  202. bool unpack(LLDataPacker& dp) override;
  203. bool operator==(const LLNetworkData& data) const override;
  204. void copy(const LLNetworkData& data) override;
  205. LLSD asLLSD() const;
  206. LL_INLINE operator LLSD() const { return asLLSD(); }
  207. bool fromLLSD(LLSD& sd);
  208. LL_INLINE void setLightTexture(const LLUUID& id) { mLightTexture = id; }
  209. LL_INLINE const LLUUID& getLightTexture() const { return mLightTexture; }
  210. LL_INLINE bool isLightSpotlight() const { return mLightTexture.notNull(); }
  211. LL_INLINE void setParams(const LLVector3& params) { mParams = params; }
  212. LL_INLINE LLVector3 getParams() const { return mParams; }
  213. protected:
  214. LLUUID mLightTexture;
  215. LLVector3 mParams;
  216. };
  217. class LLExtendedMeshParams : public LLNetworkData
  218. {
  219. public:
  220. LLExtendedMeshParams();
  221. bool pack(LLDataPacker& dp) const override;
  222. bool unpack(LLDataPacker& dp) override;
  223. bool operator==(const LLNetworkData& data) const override;
  224. void copy(const LLNetworkData& data) override;
  225. LL_INLINE operator LLSD() const { return asLLSD(); }
  226. LLSD asLLSD() const;
  227. bool fromLLSD(LLSD& sd);
  228. LL_INLINE void setFlags(U32 flags) { mFlags = flags; }
  229. LL_INLINE U32 getFlags() const { return mFlags; }
  230. public:
  231. static constexpr U32 ANIMATED_MESH_ENABLED_FLAG = 0x1 << 0;
  232. protected:
  233. U32 mFlags;
  234. };
  235. // Relfection probes constants:
  236. extern const F32 REFLECTION_PROBE_MIN_AMBIANCE;
  237. extern const F32 REFLECTION_PROBE_MAX_AMBIANCE;
  238. extern const F32 REFLECTION_PROBE_DEFAULT_AMBIANCE;
  239. extern const F32 REFLECTION_PROBE_MIN_CLIP_DISTANCE;
  240. extern const F32 REFLECTION_PROBE_MAX_CLIP_DISTANCE;
  241. extern const F32 REFLECTION_PROBE_DEFAULT_CLIP_DISTANCE;
  242. class LLReflectionProbeParams : public LLNetworkData
  243. {
  244. public:
  245. LLReflectionProbeParams();
  246. bool pack(LLDataPacker& dp) const override;
  247. bool unpack(LLDataPacker& dp) override;
  248. bool operator==(const LLNetworkData& data) const override;
  249. void copy(const LLNetworkData& data) override;
  250. LL_INLINE operator LLSD() const { return asLLSD(); }
  251. LLSD asLLSD() const;
  252. bool fromLLSD(LLSD& sd);
  253. enum EFlags : U8
  254. {
  255. FLAG_BOX_VOLUME = 0x01, // Use a box influence volume
  256. FLAG_DYNAMIC = 0x02, // Render dynamic objects (avatars)
  257. // into this reflection probe.
  258. FLAG_MIRROR = 0x04, // Probe used for real time mirrors.
  259. };
  260. LL_INLINE void setAmbiance(F32 val)
  261. {
  262. mAmbiance = llclamp(val, REFLECTION_PROBE_MIN_AMBIANCE,
  263. REFLECTION_PROBE_MAX_AMBIANCE);
  264. }
  265. LL_INLINE F32 getAmbiance() const { return mAmbiance; }
  266. LL_INLINE void setClipDistance(F32 dist)
  267. {
  268. mClipDistance = llclamp(dist, REFLECTION_PROBE_MIN_CLIP_DISTANCE,
  269. REFLECTION_PROBE_MAX_CLIP_DISTANCE);
  270. }
  271. LL_INLINE F32 getClipDistance() const { return mClipDistance; }
  272. LL_INLINE void setIsBox(bool is_box)
  273. {
  274. if (is_box)
  275. {
  276. mFlags |= FLAG_BOX_VOLUME;
  277. }
  278. else
  279. {
  280. mFlags &= ~FLAG_BOX_VOLUME;
  281. }
  282. }
  283. LL_INLINE bool getIsBox() const
  284. {
  285. return (mFlags & FLAG_BOX_VOLUME) != 0;
  286. }
  287. LL_INLINE void setIsDynamic(bool is_dynamic)
  288. {
  289. if (is_dynamic)
  290. {
  291. mFlags |= FLAG_DYNAMIC;
  292. }
  293. else
  294. {
  295. mFlags &= ~FLAG_DYNAMIC;
  296. }
  297. }
  298. LL_INLINE bool getIsDynamic() const
  299. {
  300. return (mFlags & FLAG_DYNAMIC) != 0;
  301. }
  302. LL_INLINE void setIsMirror(bool is_mirror)
  303. {
  304. if (is_mirror)
  305. {
  306. mFlags |= FLAG_MIRROR;
  307. }
  308. else
  309. {
  310. mFlags &= ~FLAG_MIRROR;
  311. }
  312. }
  313. LL_INLINE bool getIsMirror() const
  314. {
  315. return (mFlags & FLAG_MIRROR) != 0;
  316. }
  317. protected:
  318. F32 mAmbiance;
  319. F32 mClipDistance;
  320. U8 mFlags;
  321. };
  322. class LLRenderMaterialParams : public LLNetworkData
  323. {
  324. public:
  325. LLRenderMaterialParams();
  326. bool pack(LLDataPacker& dp) const override;
  327. bool unpack(LLDataPacker& dp) override;
  328. bool operator==(const LLNetworkData& data) const override;
  329. void copy(const LLNetworkData& data) override;
  330. #if 0 // Not used
  331. LL_INLINE operator LLSD() const { return asLLSD(); }
  332. LLSD asLLSD() const;
  333. bool fromLLSD(LLSD& sd);
  334. #endif
  335. void setMaterial(U8 te_idx, const LLUUID& id);
  336. const LLUUID& getMaterial(U8 te_idx) const;
  337. LL_INLINE bool isEmpty() const { return mEntries.empty(); }
  338. protected:
  339. struct Entry
  340. {
  341. Entry() = default;
  342. Entry(U8 idx, LLUUID uuid)
  343. : te_idx(idx),
  344. id(uuid)
  345. {
  346. }
  347. LLUUID id;
  348. U8 te_idx;
  349. };
  350. std::vector<Entry> mEntries;
  351. };
  352. // This code is not naming-standards compliant. Leaving it like this for now to
  353. // make the connection to code in packTEMessage(LLDataPacker&) more obvious.
  354. // This should be refactored to remove the duplication, at which point we can
  355. // fix the names as well. - Vir
  356. struct LLTEContents
  357. {
  358. LLUUID image_data[MAX_TES];
  359. LLColor4U colors[MAX_TES];
  360. F32 scale_s[MAX_TES];
  361. F32 scale_t[MAX_TES];
  362. S16 offset_s[MAX_TES];
  363. S16 offset_t[MAX_TES];
  364. S16 image_rot[MAX_TES];
  365. U8 bump[MAX_TES];
  366. U8 media_flags[MAX_TES];
  367. U8 glow[MAX_TES];
  368. LLMaterialID material_ids[MAX_TES];
  369. U8 packed_buffer[MAX_TE_BUFFER];
  370. U32 size;
  371. U32 face_count;
  372. };
  373. class LLPrimitive : public LLXform
  374. {
  375. protected:
  376. LOG_CLASS(LLPrimitive);
  377. public:
  378. // Allows to change the limits for prim parameters for SL or OpenSim
  379. static void setLimits(bool for_secondlife);
  380. // These flags influence how the RigidBody representation is built
  381. static constexpr U32 PRIM_FLAG_PHANTOM = 0x1 << 0;
  382. static constexpr U32 PRIM_FLAG_VOLUME_DETECT = 0x1 << 1;
  383. static constexpr U32 PRIM_FLAG_DYNAMIC = 0x1 << 2;
  384. static constexpr U32 PRIM_FLAG_AVATAR = 0x1 << 3;
  385. static constexpr U32 PRIM_FLAG_SCULPT = 0x1 << 4;
  386. // Not used yet, but soon
  387. static constexpr U32 PRIM_FLAG_COLLISION_CALLBACK = 0x1 << 5;
  388. static constexpr U32 PRIM_FLAG_CONVEX = 0x1 << 6;
  389. static constexpr U32 PRIM_FLAG_DEFAULT_VOLUME = 0x1 << 7;
  390. static constexpr U32 PRIM_FLAG_SITTING = 0x1 << 8;
  391. // Set along with PRIM_FLAG_SITTING
  392. static constexpr U32 PRIM_FLAG_SITTING_ON_GROUND = 0x1 << 9;
  393. LLPrimitive();
  394. ~LLPrimitive() override;
  395. // *HACK: for Windoze confusion about ostream operator in LLVolume:
  396. LL_INLINE const LLVolume* getVolumeConst() const { return mVolumep; }
  397. LL_INLINE LLVolume* getVolume() const { return mVolumep; }
  398. virtual bool setVolume(const LLVolumeParams& volume_params,
  399. S32 detail, bool unique_volume = false);
  400. // Modify texture entry properties
  401. LL_INLINE bool validTE(U8 te_num) const { return mNumTEs && te_num < mNumTEs; }
  402. LLTextureEntry* getTE(U8 te_num) const;
  403. virtual void setNumTEs(U8 num_tes);
  404. virtual void setAllTESelected(bool sel);
  405. virtual void setAllTETextures(const LLUUID& tex_id);
  406. virtual void setTE(U8 index, const LLTextureEntry& te);
  407. virtual S32 setTEColor(U8 te, const LLColor4& color);
  408. virtual S32 setTEColor(U8 te, const LLColor3& color);
  409. virtual S32 setTEAlpha(U8 te, F32 alpha);
  410. virtual S32 setTETexture(U8 te, const LLUUID& tex_id);
  411. virtual S32 setTEScale(U8 te, F32 s, F32 t);
  412. virtual S32 setTEScaleS(U8 te, F32 s);
  413. virtual S32 setTEScaleT(U8 te, F32 t);
  414. virtual S32 setTEOffset(U8 te, F32 s, F32 t);
  415. virtual S32 setTEOffsetS(U8 te, F32 s);
  416. virtual S32 setTEOffsetT(U8 te, F32 t);
  417. virtual S32 setTERotation(U8 te, F32 r);
  418. virtual S32 setTEBumpShinyFullbright(U8 te, U8 bump);
  419. virtual S32 setTEBumpShiny(U8 te, U8 bump);
  420. virtual S32 setTEMediaTexGen(U8 te, U8 media);
  421. virtual S32 setTEBumpmap(U8 te, U8 bump);
  422. virtual S32 setTETexGen(U8 te, U8 texgen);
  423. virtual S32 setTEShiny(U8 te, U8 shiny);
  424. virtual S32 setTEFullbright(U8 te, U8 fullbright);
  425. virtual S32 setTEMediaFlags(U8 te, U8 flags);
  426. virtual S32 setTEGlow(U8 te, F32 glow);
  427. virtual S32 setTEMaterialID(U8 te, const LLMaterialID& matidp);
  428. virtual S32 setTEMaterialParams(U8 index, const LLMaterialPtr paramsp);
  429. // Returns true if material changed:
  430. virtual bool setMaterial(U8 material);
  431. void setTESelected(U8 te, bool sel);
  432. LLMaterialPtr getTEMaterialParams(U8 index);
  433. void copyTEs(const LLPrimitive* primitive);
  434. S32 packTEField(U8* cur_ptr, U8* data_ptr, U8 data_size,
  435. U8 last_face_index, EMsgVariableType type) const;
  436. void packTEMessage(LLMessageSystem* mesgsys) const;
  437. void packTEMessage(LLDataPacker& dp) const;
  438. S32 unpackTEMessage(LLMessageSystem* mesgsys, char const* block_name,
  439. S32 block_num); // Variable num of blocks
  440. S32 unpackTEMessage(LLDataPacker& dp);
  441. S32 parseTEMessage(LLMessageSystem* mesgsys, char const* block_name,
  442. S32 block_num, LLTEContents& tec);
  443. S32 applyParsedTEMessage(LLTEContents& tec);
  444. LL_INLINE void setAngularVelocity(const LLVector3& avel)
  445. {
  446. mAngularVelocity = avel;
  447. }
  448. LL_INLINE void setAngularVelocity(F32 x, F32 y, F32 z)
  449. {
  450. mAngularVelocity.set(x, y, z);
  451. }
  452. LL_INLINE void setVelocity(const LLVector3& vel) { mVelocity = vel; }
  453. LL_INLINE void setVelocity(F32 x, F32 y, F32 z)
  454. {
  455. mVelocity.set(x, y, z);
  456. }
  457. LL_INLINE void setVelocityX(F32 x) { mVelocity.mV[VX] = x; }
  458. LL_INLINE void setVelocityY(F32 y) { mVelocity.mV[VY] = y; }
  459. LL_INLINE void setVelocityZ(F32 z) { mVelocity.mV[VZ] = z; }
  460. LL_INLINE void addVelocity(const LLVector3& vel) { mVelocity += vel; }
  461. LL_INLINE void setAcceleration(const LLVector3& a) { mAcceleration = a; }
  462. LL_INLINE void setAcceleration(F32 x, F32 y, F32 z)
  463. {
  464. mAcceleration.set(x, y, z);
  465. }
  466. LL_INLINE LLPCode getPCode() const { return mPrimitiveCode; }
  467. LL_INLINE std::string getPCodeString() const { return pCodeToString(mPrimitiveCode); }
  468. void setPCode(LLPCode p_code);
  469. LL_INLINE const LLVector3& getAngularVelocity() const
  470. {
  471. return mAngularVelocity;
  472. }
  473. LL_INLINE const LLVector3& getVelocity() const { return mVelocity; }
  474. LL_INLINE const LLVector3& getAcceleration() const { return mAcceleration; }
  475. LL_INLINE U8 getNumTEs() const { return mTextureList.size(); }
  476. LL_INLINE U8 getExpectedNumTEs() const;
  477. LL_INLINE U8 getMaterial() const { return mMaterial; }
  478. U8 getVolumeType();
  479. // Clears existing textures; copies the contents of other_list into
  480. // mEntryList
  481. void copyTextureList(const LLPrimTextureList& other_list);
  482. // Clears existing textures; takes the contents of other_list and clears it
  483. void takeTextureList(LLPrimTextureList& other_list);
  484. LL_INLINE bool hasBumpmap() const { return mNumBumpmapTEs > 0; }
  485. LL_INLINE void setFlags(U32 flags) { mMiscFlags = flags; }
  486. LL_INLINE void addFlags(U32 flags) { mMiscFlags |= flags; }
  487. LL_INLINE void removeFlags(U32 flags) { mMiscFlags &= ~flags; }
  488. LL_INLINE U32 getFlags() const { return mMiscFlags; }
  489. static std::string pCodeToString(LLPCode pcode);
  490. static bool getTESTAxes(U8 face, U32* s_axis, U32* t_axis);
  491. LL_INLINE static bool isPrimitive(LLPCode pcode)
  492. {
  493. LLPCode base_type = pcode & LL_PCODE_BASE_MASK;
  494. return base_type && base_type < LL_PCODE_APP;
  495. }
  496. LL_INLINE static bool isApp(LLPCode pcode)
  497. {
  498. LLPCode base_type = pcode & LL_PCODE_BASE_MASK;
  499. return base_type == LL_PCODE_APP;
  500. }
  501. private:
  502. void updateNumBumpmap(U8 index, U8 bump);
  503. protected:
  504. LLPointer<LLVolume> mVolumep;
  505. LLVector3 mVelocity; // Moving speed
  506. LLVector3 mAcceleration; // Constant acceleration
  507. LLVector3 mAngularVelocity; // Angular velocity
  508. LLPrimTextureList mTextureList; // List of textures data
  509. U32 mMiscFlags; // Home for misc bools
  510. LLPCode mPrimitiveCode; // Primitive code
  511. U8 mMaterial; // Material code
  512. U8 mNumTEs; // Number of faces on the primitve
  513. U8 mNumBumpmapTEs; // Number of bumpmap TEs.
  514. };
  515. #endif