/indra/newview/llviewerobject.h

https://bitbucket.org/lindenlab/viewer-beta/ · C Header · 834 lines · 549 code · 164 blank · 121 comment · 15 complexity · 9d25ed43e68d285c82a006ab209a9c0a MD5 · raw file

  1. /**
  2. * @file llviewerobject.h
  3. * @brief Description of LLViewerObject class, which is the base class for most objects in the viewer.
  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_LLVIEWEROBJECT_H
  27. #define LL_LLVIEWEROBJECT_H
  28. #include <map>
  29. #include "llassetstorage.h"
  30. #include "lldarrayptr.h"
  31. #include "llhudicon.h"
  32. #include "llinventory.h"
  33. #include "llrefcount.h"
  34. #include "llmemtype.h"
  35. #include "llprimitive.h"
  36. #include "lluuid.h"
  37. #include "llvoinventorylistener.h"
  38. #include "object_flags.h"
  39. #include "llquaternion.h"
  40. #include "v3dmath.h"
  41. #include "v3math.h"
  42. #include "llvertexbuffer.h"
  43. #include "llbbox.h"
  44. #include "llbbox.h"
  45. class LLAgent; // TODO: Get rid of this.
  46. class LLAudioSource;
  47. class LLAudioSourceVO;
  48. class LLDataPacker;
  49. class LLColor4;
  50. class LLFrameTimer;
  51. class LLDrawable;
  52. class LLHost;
  53. class LLHUDText;
  54. class LLWorld;
  55. class LLNameValue;
  56. class LLNetMap;
  57. class LLMessageSystem;
  58. class LLPartSysData;
  59. class LLPrimitive;
  60. class LLPipeline;
  61. class LLTextureEntry;
  62. class LLViewerTexture;
  63. class LLViewerInventoryItem;
  64. class LLViewerObject;
  65. class LLViewerPartSourceScript;
  66. class LLViewerRegion;
  67. class LLViewerObjectMedia;
  68. class LLVOInventoryListener;
  69. class LLVOAvatar;
  70. typedef enum e_object_update_type
  71. {
  72. OUT_FULL,
  73. OUT_TERSE_IMPROVED,
  74. OUT_FULL_COMPRESSED,
  75. OUT_FULL_CACHED,
  76. OUT_UNKNOWN,
  77. } EObjectUpdateType;
  78. // callback typedef for inventory
  79. typedef void (*inventory_callback)(LLViewerObject*,
  80. LLInventoryObject::object_list_t*,
  81. S32 serial_num,
  82. void*);
  83. // a small struct for keeping track of joints
  84. struct LLVOJointInfo
  85. {
  86. EHavokJointType mJointType;
  87. LLVector3 mPivot; // parent-frame
  88. // whether the below an axis or anchor (and thus its frame)
  89. // depends on the joint type:
  90. // HINGE ==> axis=parent-frame
  91. // P2P ==> anchor=child-frame
  92. LLVector3 mAxisOrAnchor;
  93. };
  94. // for exporting textured materials from SL
  95. struct LLMaterialExportInfo
  96. {
  97. public:
  98. LLMaterialExportInfo(S32 mat_index, S32 texture_index, LLColor4 color) :
  99. mMaterialIndex(mat_index), mTextureIndex(texture_index), mColor(color) {};
  100. S32 mMaterialIndex;
  101. S32 mTextureIndex;
  102. LLColor4 mColor;
  103. };
  104. struct PotentialReturnableObject
  105. {
  106. LLBBox box;
  107. LLViewerRegion* pRegion;
  108. };
  109. //============================================================================
  110. class LLViewerObject : public LLPrimitive, public LLRefCount, public LLGLUpdate
  111. {
  112. protected:
  113. ~LLViewerObject(); // use unref()
  114. // TomY: Provide for a list of extra parameter structures, mapped by structure name
  115. struct ExtraParameter
  116. {
  117. BOOL in_use;
  118. LLNetworkData *data;
  119. };
  120. std::map<U16, ExtraParameter*> mExtraParameterList;
  121. public:
  122. typedef std::list<LLPointer<LLViewerObject> > child_list_t;
  123. typedef std::list<LLPointer<LLViewerObject> > vobj_list_t;
  124. typedef const child_list_t const_child_list_t;
  125. LLViewerObject(const LLUUID &id, const LLPCode pcode, LLViewerRegion *regionp, BOOL is_global = FALSE);
  126. MEM_TYPE_NEW(LLMemType::MTYPE_OBJECT);
  127. virtual void markDead(); // Mark this object as dead, and clean up its references
  128. BOOL isDead() const {return mDead;}
  129. BOOL isOrphaned() const { return mOrphaned; }
  130. BOOL isParticleSource() const;
  131. virtual LLVOAvatar* asAvatar();
  132. static void initVOClasses();
  133. static void cleanupVOClasses();
  134. void addNVPair(const std::string& data);
  135. BOOL removeNVPair(const std::string& name);
  136. LLNameValue* getNVPair(const std::string& name) const; // null if no name value pair by that name
  137. // Object create and update functions
  138. virtual BOOL idleUpdate(LLAgent &agent, LLWorld &world, const F64 &time);
  139. // Types of media we can associate
  140. enum { MEDIA_NONE = 0, MEDIA_SET = 1 };
  141. // Return codes for processUpdateMessage
  142. enum {
  143. MEDIA_URL_REMOVED = 0x1,
  144. MEDIA_URL_ADDED = 0x2,
  145. MEDIA_URL_UPDATED = 0x4,
  146. MEDIA_FLAGS_CHANGED = 0x8,
  147. INVALID_UPDATE = 0x80000000
  148. };
  149. virtual U32 processUpdateMessage(LLMessageSystem *mesgsys,
  150. void **user_data,
  151. U32 block_num,
  152. const EObjectUpdateType update_type,
  153. LLDataPacker *dp);
  154. virtual BOOL isActive() const; // Whether this object needs to do an idleUpdate.
  155. BOOL onActiveList() const {return mOnActiveList;}
  156. void setOnActiveList(BOOL on_active) { mOnActiveList = on_active; }
  157. virtual BOOL isAttachment() const { return FALSE; }
  158. virtual LLVOAvatar* getAvatar() const; //get the avatar this object is attached to, or NULL if object is not an attachment
  159. virtual BOOL isHUDAttachment() const { return FALSE; }
  160. virtual void updateRadius() {};
  161. virtual F32 getVObjRadius() const; // default implemenation is mDrawable->getRadius()
  162. BOOL isJointChild() const { return mJointInfo ? TRUE : FALSE; }
  163. EHavokJointType getJointType() const { return mJointInfo ? mJointInfo->mJointType : HJT_INVALID; }
  164. // for jointed and other parent-relative hacks
  165. LLViewerObject* getSubParent();
  166. const LLViewerObject* getSubParent() const;
  167. // Object visiblility and GPW functions
  168. virtual void setPixelAreaAndAngle(LLAgent &agent); // Override to generate accurate apparent angle and area
  169. virtual U32 getNumVertices() const;
  170. virtual U32 getNumIndices() const;
  171. S32 getNumFaces() const { return mNumFaces; }
  172. // Graphical stuff for objects - maybe broken out into render class later?
  173. virtual void updateTextures();
  174. virtual void boostTexturePriority(BOOL boost_children = TRUE); // When you just want to boost priority of this object
  175. virtual LLDrawable* createDrawable(LLPipeline *pipeline);
  176. virtual BOOL updateGeometry(LLDrawable *drawable);
  177. virtual void updateGL();
  178. virtual void updateFaceSize(S32 idx);
  179. virtual BOOL updateLOD();
  180. virtual BOOL setDrawableParent(LLDrawable* parentp);
  181. F32 getRotTime() { return mRotTime; }
  182. void resetRot();
  183. void applyAngularVelocity(F32 dt);
  184. void setLineWidthForWindowSize(S32 window_width);
  185. static void increaseArrowLength(); // makes axis arrows for selections longer
  186. static void decreaseArrowLength(); // makes axis arrows for selections shorter
  187. // Accessor functions
  188. LLViewerRegion* getRegion() const { return mRegionp; }
  189. BOOL isSelected() const { return mUserSelected; }
  190. virtual void setSelected(BOOL sel) { mUserSelected = sel; mRotTime = 0.f;}
  191. const LLUUID &getID() const { return mID; }
  192. U32 getLocalID() const { return mLocalID; }
  193. U32 getCRC() const { return mTotalCRC; }
  194. virtual BOOL isFlexible() const { return FALSE; }
  195. virtual BOOL isSculpted() const { return FALSE; }
  196. virtual BOOL isMesh() const { return FALSE; }
  197. virtual BOOL hasLightTexture() const { return FALSE; }
  198. // This method returns true if the object is over land owned by
  199. // the agent, one of its groups, or it encroaches and
  200. // anti-encroachment is enabled
  201. bool isReturnable();
  202. void buildReturnablesForChildrenVO( std::vector<PotentialReturnableObject>& returnables, LLViewerObject* pChild, LLViewerRegion* pTargetRegion );
  203. void constructAndAddReturnable( std::vector<PotentialReturnableObject>& returnables, LLViewerObject* pChild, LLViewerRegion* pTargetRegion );
  204. // This method returns true if the object crosses
  205. // any parcel bounds in the region.
  206. bool crossesParcelBounds();
  207. /*
  208. // This method will scan through this object, and then query the
  209. // selection manager to see if the local agent probably has the
  210. // ability to modify the object. Since this calls into the
  211. // selection manager, you should avoid calling this method from
  212. // there.
  213. BOOL isProbablyModifiable() const;
  214. */
  215. virtual BOOL setParent(LLViewerObject* parent);
  216. virtual void addChild(LLViewerObject *childp);
  217. virtual void removeChild(LLViewerObject *childp);
  218. const_child_list_t& getChildren() const { return mChildList; }
  219. S32 numChildren() const { return mChildList.size(); }
  220. void addThisAndAllChildren(std::vector<LLViewerObject*>& objects);
  221. void addThisAndNonJointChildren(std::vector<LLViewerObject*>& objects);
  222. BOOL isChild(LLViewerObject *childp) const;
  223. BOOL isSeat() const;
  224. //detect if given line segment (in agent space) intersects with this viewer object.
  225. //returns TRUE if intersection detected and returns information about intersection
  226. virtual BOOL lineSegmentIntersect(const LLVector3& start, const LLVector3& end,
  227. S32 face = -1, // which face to check, -1 = ALL_SIDES
  228. BOOL pick_transparent = FALSE,
  229. S32* face_hit = NULL, // which face was hit
  230. LLVector3* intersection = NULL, // return the intersection point
  231. LLVector2* tex_coord = NULL, // return the texture coordinates of the intersection point
  232. LLVector3* normal = NULL, // return the surface normal at the intersection point
  233. LLVector3* bi_normal = NULL // return the surface bi-normal at the intersection point
  234. );
  235. virtual BOOL lineSegmentBoundingBox(const LLVector3& start, const LLVector3& end);
  236. virtual const LLVector3d getPositionGlobal() const;
  237. virtual const LLVector3 &getPositionRegion() const;
  238. virtual const LLVector3 getPositionEdit() const;
  239. virtual const LLVector3 &getPositionAgent() const;
  240. virtual const LLVector3 getRenderPosition() const;
  241. virtual const LLVector3 getPivotPositionAgent() const; // Usually = to getPositionAgent, unless like flex objects it's not
  242. LLViewerObject* getRootEdit() const;
  243. const LLQuaternion getRotationRegion() const;
  244. const LLQuaternion getRotationEdit() const;
  245. const LLQuaternion getRenderRotation() const;
  246. virtual const LLMatrix4 getRenderMatrix() const;
  247. void setPosition(const LLVector3 &pos, BOOL damped = FALSE);
  248. void setPositionGlobal(const LLVector3d &position, BOOL damped = FALSE);
  249. void setPositionRegion(const LLVector3 &position, BOOL damped = FALSE);
  250. void setPositionEdit(const LLVector3 &position, BOOL damped = FALSE);
  251. void setPositionAgent(const LLVector3 &pos_agent, BOOL damped = FALSE);
  252. void setPositionParent(const LLVector3 &pos_parent, BOOL damped = FALSE);
  253. void setPositionAbsoluteGlobal( const LLVector3d &pos_global, BOOL damped = FALSE );
  254. virtual const LLMatrix4& getWorldMatrix(LLXformMatrix* xform) const { return xform->getWorldMatrix(); }
  255. inline void setRotation(const F32 x, const F32 y, const F32 z, BOOL damped = FALSE);
  256. inline void setRotation(const LLQuaternion& quat, BOOL damped = FALSE);
  257. void sendRotationUpdate() const;
  258. /*virtual*/ void setNumTEs(const U8 num_tes);
  259. /*virtual*/ void setTE(const U8 te, const LLTextureEntry &texture_entry);
  260. /*virtual*/ S32 setTETexture(const U8 te, const LLUUID &uuid);
  261. S32 setTETextureCore(const U8 te, const LLUUID& uuid, LLHost host);
  262. /*virtual*/ S32 setTEColor(const U8 te, const LLColor3 &color);
  263. /*virtual*/ S32 setTEColor(const U8 te, const LLColor4 &color);
  264. /*virtual*/ S32 setTEScale(const U8 te, const F32 s, const F32 t);
  265. /*virtual*/ S32 setTEScaleS(const U8 te, const F32 s);
  266. /*virtual*/ S32 setTEScaleT(const U8 te, const F32 t);
  267. /*virtual*/ S32 setTEOffset(const U8 te, const F32 s, const F32 t);
  268. /*virtual*/ S32 setTEOffsetS(const U8 te, const F32 s);
  269. /*virtual*/ S32 setTEOffsetT(const U8 te, const F32 t);
  270. /*virtual*/ S32 setTERotation(const U8 te, const F32 r);
  271. /*virtual*/ S32 setTEBumpmap(const U8 te, const U8 bump );
  272. /*virtual*/ S32 setTETexGen(const U8 te, const U8 texgen );
  273. /*virtual*/ S32 setTEMediaTexGen(const U8 te, const U8 media ); // *FIXME: this confusingly acts upon a superset of setTETexGen's flags without absorbing its semantics
  274. /*virtual*/ S32 setTEShiny(const U8 te, const U8 shiny );
  275. /*virtual*/ S32 setTEFullbright(const U8 te, const U8 fullbright );
  276. /*virtual*/ S32 setTEMediaFlags(const U8 te, const U8 media_flags );
  277. /*virtual*/ S32 setTEGlow(const U8 te, const F32 glow);
  278. /*virtual*/ BOOL setMaterial(const U8 material);
  279. virtual void setTEImage(const U8 te, LLViewerTexture *imagep); // Not derived from LLPrimitive
  280. void changeTEImage(S32 index, LLViewerTexture* new_image) ;
  281. LLViewerTexture *getTEImage(const U8 te) const;
  282. void fitFaceTexture(const U8 face);
  283. void sendTEUpdate() const; // Sends packed representation of all texture entry information
  284. virtual void setScale(const LLVector3 &scale, BOOL damped = FALSE);
  285. virtual F32 getStreamingCost(S32* bytes = NULL, S32* visible_bytes = NULL, F32* unscaled_value = NULL) const;
  286. virtual U32 getTriangleCount(S32* vcount = NULL) const;
  287. virtual U32 getHighLODTriangleCount();
  288. void setObjectCost(F32 cost);
  289. F32 getObjectCost();
  290. void setLinksetCost(F32 cost);
  291. F32 getLinksetCost();
  292. void setPhysicsCost(F32 cost);
  293. F32 getPhysicsCost();
  294. void setLinksetPhysicsCost(F32 cost);
  295. F32 getLinksetPhysicsCost();
  296. void sendShapeUpdate();
  297. U8 getState() { return mState; }
  298. F32 getAppAngle() const { return mAppAngle; }
  299. F32 getPixelArea() const { return mPixelArea; }
  300. void setPixelArea(F32 area) { mPixelArea = area; }
  301. F32 getMaxScale() const;
  302. F32 getMidScale() const;
  303. F32 getMinScale() const;
  304. // Owner id is this object's owner
  305. void setAttachedSound(const LLUUID &audio_uuid, const LLUUID& owner_id, const F32 gain, const U8 flags);
  306. void adjustAudioGain(const F32 gain);
  307. void clearAttachedSound() { mAudioSourcep = NULL; }
  308. // Create if necessary
  309. LLAudioSource *getAudioSource(const LLUUID& owner_id);
  310. bool isAudioSource() {return mAudioSourcep != NULL;}
  311. U8 getMediaType() const;
  312. void setMediaType(U8 media_type);
  313. std::string getMediaURL() const;
  314. void setMediaURL(const std::string& media_url);
  315. BOOL getMediaPassedWhitelist() const;
  316. void setMediaPassedWhitelist(BOOL passed);
  317. void sendMaterialUpdate() const;
  318. void setCanSelect(BOOL canSelect);
  319. void setDebugText(const std::string &utf8text);
  320. void setIcon(LLViewerTexture* icon_image);
  321. void clearIcon();
  322. void markForUpdate(BOOL priority);
  323. void updateVolume(const LLVolumeParams& volume_params);
  324. virtual void updateSpatialExtents(LLVector4a& min, LLVector4a& max);
  325. virtual F32 getBinRadius();
  326. LLBBox getBoundingBoxAgent() const;
  327. void updatePositionCaches() const; // Update the global and region position caches from the object (and parent's) xform.
  328. void updateText(); // update text label position
  329. virtual void updateDrawable(BOOL force_damped); // force updates on static objects
  330. void setDrawableState(U32 state, BOOL recursive = TRUE);
  331. void clearDrawableState(U32 state, BOOL recursive = TRUE);
  332. // Called when the drawable shifts
  333. virtual void onShift(const LLVector4a &shift_vector) { }
  334. //////////////////////////////////////
  335. //
  336. // Inventory methods
  337. //
  338. // This function is called when someone is interested in a viewer
  339. // object's inventory. The callback is called as soon as the
  340. // viewer object has the inventory stored locally.
  341. void registerInventoryListener(LLVOInventoryListener* listener, void* user_data);
  342. void removeInventoryListener(LLVOInventoryListener* listener);
  343. BOOL isInventoryPending() { return mInventoryPending; }
  344. void clearInventoryListeners();
  345. void requestInventory();
  346. void fetchInventoryFromServer();
  347. static void processTaskInv(LLMessageSystem* msg, void** user_data);
  348. void removeInventory(const LLUUID& item_id);
  349. // The updateInventory() call potentially calls into the selection
  350. // manager, so do no call updateInventory() from the selection
  351. // manager until we have better iterators.
  352. void updateInventory(LLViewerInventoryItem* item, U8 key, bool is_new);
  353. void updateInventoryLocal(LLInventoryItem* item, U8 key); // Update without messaging.
  354. LLInventoryObject* getInventoryObject(const LLUUID& item_id);
  355. void getInventoryContents(LLInventoryObject::object_list_t& objects);
  356. LLInventoryObject* getInventoryRoot();
  357. LLViewerInventoryItem* getInventoryItemByAsset(const LLUUID& asset_id);
  358. S16 getInventorySerial() const { return mInventorySerialNum; }
  359. // These functions does viewer-side only object inventory modifications
  360. void updateViewerInventoryAsset(
  361. const LLViewerInventoryItem* item,
  362. const LLUUID& new_asset);
  363. // This function will make sure that we refresh the inventory.
  364. void dirtyInventory();
  365. BOOL isInventoryDirty() { return mInventoryDirty; }
  366. // save a script, which involves removing the old one, and rezzing
  367. // in the new one. This method should be called with the asset id
  368. // of the new and old script AFTER the bytecode has been saved.
  369. void saveScript(const LLViewerInventoryItem* item, BOOL active, bool is_new);
  370. // move an inventory item out of the task and into agent
  371. // inventory. This operation is based on messaging. No permissions
  372. // checks are made on the viewer - the server will double check.
  373. void moveInventory(const LLUUID& agent_folder, const LLUUID& item_id);
  374. // Find the number of instances of this object's inventory that are of the given type
  375. S32 countInventoryContents( LLAssetType::EType type );
  376. BOOL permAnyOwner() const;
  377. BOOL permYouOwner() const;
  378. BOOL permGroupOwner() const;
  379. BOOL permOwnerModify() const;
  380. BOOL permModify() const;
  381. BOOL permCopy() const;
  382. BOOL permMove() const;
  383. BOOL permTransfer() const;
  384. inline BOOL usePhysics() const { return ((mFlags & FLAGS_USE_PHYSICS) != 0); }
  385. inline BOOL flagScripted() const { return ((mFlags & FLAGS_SCRIPTED) != 0); }
  386. inline BOOL flagHandleTouch() const { return ((mFlags & FLAGS_HANDLE_TOUCH) != 0); }
  387. inline BOOL flagTakesMoney() const { return ((mFlags & FLAGS_TAKES_MONEY) != 0); }
  388. inline BOOL flagPhantom() const { return ((mFlags & FLAGS_PHANTOM) != 0); }
  389. inline BOOL flagInventoryEmpty() const { return ((mFlags & FLAGS_INVENTORY_EMPTY) != 0); }
  390. inline BOOL flagCastShadows() const { return ((mFlags & FLAGS_CAST_SHADOWS) != 0); }
  391. inline BOOL flagAllowInventoryAdd() const { return ((mFlags & FLAGS_ALLOW_INVENTORY_DROP) != 0); }
  392. inline BOOL flagTemporary() const { return ((mFlags & FLAGS_TEMPORARY) != 0); }
  393. inline BOOL flagTemporaryOnRez() const { return ((mFlags & FLAGS_TEMPORARY_ON_REZ) != 0); }
  394. inline BOOL flagAnimSource() const { return ((mFlags & FLAGS_ANIM_SOURCE) != 0); }
  395. inline BOOL flagCameraSource() const { return ((mFlags & FLAGS_CAMERA_SOURCE) != 0); }
  396. inline BOOL flagCameraDecoupled() const { return ((mFlags & FLAGS_CAMERA_DECOUPLED) != 0); }
  397. inline BOOL flagObjectMove() const { return ((mFlags & FLAGS_OBJECT_MOVE) != 0); }
  398. U8 getPhysicsShapeType() const;
  399. inline F32 getPhysicsGravity() const { return mPhysicsGravity; }
  400. inline F32 getPhysicsFriction() const { return mPhysicsFriction; }
  401. inline F32 getPhysicsDensity() const { return mPhysicsDensity; }
  402. inline F32 getPhysicsRestitution() const { return mPhysicsRestitution; }
  403. bool getIncludeInSearch() const;
  404. void setIncludeInSearch(bool include_in_search);
  405. // Does "open" object menu item apply?
  406. BOOL allowOpen() const;
  407. void setClickAction(U8 action) { mClickAction = action; }
  408. U8 getClickAction() const { return mClickAction; }
  409. bool specialHoverCursor() const; // does it have a special hover cursor?
  410. void setRegion(LLViewerRegion *regionp);
  411. virtual void updateRegion(LLViewerRegion *regionp);
  412. void updateFlags(BOOL physics_changed = FALSE);
  413. BOOL setFlags(U32 flag, BOOL state);
  414. void setPhysicsShapeType(U8 type);
  415. void setPhysicsGravity(F32 gravity);
  416. void setPhysicsFriction(F32 friction);
  417. void setPhysicsDensity(F32 density);
  418. void setPhysicsRestitution(F32 restitution);
  419. virtual void dump() const;
  420. static U32 getNumZombieObjects() { return sNumZombieObjects; }
  421. void printNameValuePairs() const;
  422. virtual S32 getLOD() const { return 3; }
  423. virtual U32 getPartitionType() const;
  424. virtual void dirtySpatialGroup(BOOL priority = FALSE) const;
  425. virtual void dirtyMesh();
  426. virtual LLNetworkData* getParameterEntry(U16 param_type) const;
  427. virtual bool setParameterEntry(U16 param_type, const LLNetworkData& new_value, bool local_origin);
  428. virtual BOOL getParameterEntryInUse(U16 param_type) const;
  429. virtual bool setParameterEntryInUse(U16 param_type, BOOL in_use, bool local_origin);
  430. // Called when a parameter is changed
  431. virtual void parameterChanged(U16 param_type, bool local_origin);
  432. virtual void parameterChanged(U16 param_type, LLNetworkData* data, BOOL in_use, bool local_origin);
  433. friend class LLViewerObjectList;
  434. friend class LLViewerMediaList;
  435. public:
  436. //counter-translation
  437. void resetChildrenPosition(const LLVector3& offset, BOOL simplified = FALSE) ;
  438. //counter-rotation
  439. void resetChildrenRotationAndPosition(const std::vector<LLQuaternion>& rotations,
  440. const std::vector<LLVector3>& positions) ;
  441. void saveUnselectedChildrenRotation(std::vector<LLQuaternion>& rotations) ;
  442. void saveUnselectedChildrenPosition(std::vector<LLVector3>& positions) ;
  443. std::vector<LLVector3> mUnselectedChildrenPositions ;
  444. private:
  445. ExtraParameter* createNewParameterEntry(U16 param_type);
  446. ExtraParameter* getExtraParameterEntry(U16 param_type) const;
  447. ExtraParameter* getExtraParameterEntryCreate(U16 param_type);
  448. bool unpackParameterEntry(U16 param_type, LLDataPacker *dp);
  449. // This function checks to see if the given media URL has changed its version
  450. // and the update wasn't due to this agent's last action.
  451. U32 checkMediaURL(const std::string &media_url);
  452. // Motion prediction between updates
  453. void interpolateLinearMotion(const F64 & time, const F32 & dt);
  454. public:
  455. //
  456. // Viewer-side only types - use the LL_PCODE_APP mask.
  457. //
  458. typedef enum e_vo_types
  459. {
  460. LL_VO_CLOUDS = LL_PCODE_APP | 0x20, // no longer used
  461. LL_VO_SURFACE_PATCH = LL_PCODE_APP | 0x30,
  462. LL_VO_WL_SKY = LL_PCODE_APP | 0x40,
  463. LL_VO_SQUARE_TORUS = LL_PCODE_APP | 0x50,
  464. LL_VO_SKY = LL_PCODE_APP | 0x60,
  465. LL_VO_VOID_WATER = LL_PCODE_APP | 0x70,
  466. LL_VO_WATER = LL_PCODE_APP | 0x80,
  467. LL_VO_GROUND = LL_PCODE_APP | 0x90,
  468. LL_VO_PART_GROUP = LL_PCODE_APP | 0xa0,
  469. LL_VO_TRIANGLE_TORUS = LL_PCODE_APP | 0xb0,
  470. LL_VO_HUD_PART_GROUP = LL_PCODE_APP | 0xc0,
  471. } EVOType;
  472. typedef enum e_physics_shape_types
  473. {
  474. PHYSICS_SHAPE_PRIM = 0,
  475. PHYSICS_SHAPE_NONE,
  476. PHYSICS_SHAPE_CONVEX_HULL,
  477. } EPhysicsShapeType;
  478. LLUUID mID;
  479. // unique within region, not unique across regions
  480. // Local ID = 0 is not used
  481. U32 mLocalID;
  482. // Last total CRC received from sim, used for caching
  483. U32 mTotalCRC;
  484. LLPointer<LLViewerTexture> *mTEImages;
  485. // Selection, picking and rendering variables
  486. U32 mGLName; // GL "name" used by selection code
  487. BOOL mbCanSelect; // true if user can select this object by clicking
  488. // Grabbed from UPDATE_FLAGS
  489. U32 mFlags;
  490. // Sent to sim in UPDATE_FLAGS, received in ObjectPhysicsProperties
  491. U8 mPhysicsShapeType;
  492. F32 mPhysicsGravity;
  493. F32 mPhysicsFriction;
  494. F32 mPhysicsDensity;
  495. F32 mPhysicsRestitution;
  496. // Pipeline classes
  497. LLPointer<LLDrawable> mDrawable;
  498. // Band-aid to select object after all creation initialization is done
  499. BOOL mCreateSelected;
  500. // Replace textures with web pages on this object while drawing
  501. BOOL mRenderMedia;
  502. // In bits
  503. S32 mBestUpdatePrecision;
  504. // TODO: Make all this stuff private. JC
  505. LLPointer<LLHUDText> mText;
  506. LLPointer<LLHUDIcon> mIcon;
  507. static BOOL sUseSharedDrawables;
  508. protected:
  509. // delete an item in the inventory, but don't tell the
  510. // server. This is used internally by remove, update, and
  511. // savescript.
  512. void deleteInventoryItem(const LLUUID& item_id);
  513. // do the update/caching logic. called by saveScript and
  514. // updateInventory.
  515. void doUpdateInventory(LLPointer<LLViewerInventoryItem>& item, U8 key, bool is_new);
  516. static LLViewerObject *createObject(const LLUUID &id, LLPCode pcode, LLViewerRegion *regionp);
  517. BOOL setData(const U8 *datap, const U32 data_size);
  518. // Hide or show HUD, icon and particles
  519. void hideExtraDisplayItems( BOOL hidden );
  520. //////////////////////////
  521. //
  522. // inventory functionality
  523. //
  524. static void processTaskInvFile(void** user_data, S32 error_code, LLExtStat ext_status);
  525. void loadTaskInvFile(const std::string& filename);
  526. void doInventoryCallback();
  527. BOOL isOnMap();
  528. void unpackParticleSource(const S32 block_num, const LLUUID& owner_id);
  529. void unpackParticleSource(LLDataPacker &dp, const LLUUID& owner_id);
  530. void deleteParticleSource();
  531. void setParticleSource(const LLPartSysData& particle_parameters, const LLUUID& owner_id);
  532. public:
  533. private:
  534. void setNameValueList(const std::string& list); // clears nv pairs and then individually adds \n separated NV pairs from \0 terminated string
  535. void deleteTEImages(); // correctly deletes list of images
  536. protected:
  537. typedef std::map<char *, LLNameValue *> name_value_map_t;
  538. name_value_map_t mNameValuePairs; // Any name-value pairs stored by script
  539. child_list_t mChildList;
  540. F64 mLastInterpUpdateSecs; // Last update for purposes of interpolation
  541. F64 mLastMessageUpdateSecs; // Last update from a message from the simulator
  542. TPACKETID mLatestRecvPacketID; // Latest time stamp on message from simulator
  543. // extra data sent from the sim...currently only used for tree species info
  544. U8* mData;
  545. LLPointer<LLViewerPartSourceScript> mPartSourcep; // Particle source associated with this object.
  546. LLAudioSourceVO* mAudioSourcep;
  547. F32 mAudioGain;
  548. F32 mAppAngle; // Apparent visual arc in degrees
  549. F32 mPixelArea; // Apparent area in pixels
  550. // This is the object's inventory from the viewer's perspective.
  551. LLInventoryObject::object_list_t* mInventory;
  552. class LLInventoryCallbackInfo
  553. {
  554. public:
  555. ~LLInventoryCallbackInfo();
  556. LLVOInventoryListener* mListener;
  557. void* mInventoryData;
  558. };
  559. typedef std::list<LLInventoryCallbackInfo*> callback_list_t;
  560. callback_list_t mInventoryCallbacks;
  561. S16 mInventorySerialNum;
  562. LLViewerRegion *mRegionp; // Region that this object belongs to.
  563. BOOL mInventoryPending;
  564. BOOL mInventoryDirty;
  565. BOOL mDead;
  566. BOOL mOrphaned; // This is an orphaned child
  567. BOOL mUserSelected; // Cached user select information
  568. BOOL mOnActiveList;
  569. BOOL mOnMap; // On the map.
  570. BOOL mStatic; // Object doesn't move.
  571. S32 mNumFaces;
  572. F32 mTimeDilation; // Time dilation sent with the object.
  573. F32 mRotTime; // Amount (in seconds) that object has rotated according to angular velocity (llSetTargetOmega)
  574. LLQuaternion mLastRot; // last rotation received from the simulator
  575. LLVOJointInfo* mJointInfo;
  576. U8 mState; // legacy
  577. LLViewerObjectMedia* mMedia; // NULL if no media associated
  578. U8 mClickAction;
  579. F32 mObjectCost; //resource cost of this object or -1 if unknown
  580. F32 mLinksetCost;
  581. F32 mPhysicsCost;
  582. F32 mLinksetPhysicsCost;
  583. bool mCostStale;
  584. mutable bool mPhysicsShapeUnknown;
  585. static U32 sNumZombieObjects; // Objects which are dead, but not deleted
  586. static BOOL sMapDebug; // Map render mode
  587. static LLColor4 sEditSelectColor;
  588. static LLColor4 sNoEditSelectColor;
  589. static F32 sCurrentPulse;
  590. static BOOL sPulseEnabled;
  591. static S32 sAxisArrowLength;
  592. // These two caches are only correct for non-parented objects right now!
  593. mutable LLVector3 mPositionRegion;
  594. mutable LLVector3 mPositionAgent;
  595. static void setPhaseOutUpdateInterpolationTime(F32 value) { sPhaseOutUpdateInterpolationTime = (F64) value; }
  596. static void setMaxUpdateInterpolationTime(F32 value) { sMaxUpdateInterpolationTime = (F64) value; }
  597. static void setVelocityInterpolate(BOOL value) { sVelocityInterpolate = value; }
  598. static void setPingInterpolate(BOOL value) { sPingInterpolate = value; }
  599. private:
  600. static S32 sNumObjects;
  601. static F64 sPhaseOutUpdateInterpolationTime; // For motion interpolation
  602. static F64 sMaxUpdateInterpolationTime; // For motion interpolation
  603. static BOOL sVelocityInterpolate;
  604. static BOOL sPingInterpolate;
  605. //--------------------------------------------------------------------
  606. // For objects that are attachments
  607. //--------------------------------------------------------------------
  608. public:
  609. const LLUUID &getAttachmentItemID() const;
  610. void setAttachmentItemID(const LLUUID &id);
  611. const LLUUID &extractAttachmentItemID(); // find&set the inventory item ID of the attached object
  612. EObjectUpdateType getLastUpdateType() const;
  613. void setLastUpdateType(EObjectUpdateType last_update_type);
  614. BOOL getLastUpdateCached() const;
  615. void setLastUpdateCached(BOOL last_update_cached);
  616. private:
  617. LLUUID mAttachmentItemID; // ItemID of the associated object is in user inventory.
  618. EObjectUpdateType mLastUpdateType;
  619. BOOL mLastUpdateCached;
  620. };
  621. ///////////////////
  622. //
  623. // Inlines
  624. //
  625. //
  626. inline void LLViewerObject::setRotation(const LLQuaternion& quat, BOOL damped)
  627. {
  628. LLPrimitive::setRotation(quat);
  629. setChanged(ROTATED | SILHOUETTE);
  630. updateDrawable(damped);
  631. }
  632. inline void LLViewerObject::setRotation(const F32 x, const F32 y, const F32 z, BOOL damped)
  633. {
  634. LLPrimitive::setRotation(x, y, z);
  635. setChanged(ROTATED | SILHOUETTE);
  636. updateDrawable(damped);
  637. }
  638. class LLViewerObjectMedia
  639. {
  640. public:
  641. LLViewerObjectMedia() : mMediaURL(), mPassedWhitelist(FALSE), mMediaType(0) { }
  642. std::string mMediaURL; // for web pages on surfaces, one per prim
  643. BOOL mPassedWhitelist; // user has OK'd display
  644. U8 mMediaType; // see LLTextureEntry::WEB_PAGE, etc.
  645. };
  646. // subclass of viewer object that can be added to particle partitions
  647. class LLAlphaObject : public LLViewerObject
  648. {
  649. public:
  650. LLAlphaObject(const LLUUID &id, const LLPCode pcode, LLViewerRegion *regionp)
  651. : LLViewerObject(id,pcode,regionp)
  652. { mDepth = 0.f; }
  653. virtual F32 getPartSize(S32 idx);
  654. virtual void getGeometry(S32 idx,
  655. LLStrider<LLVector4a>& verticesp,
  656. LLStrider<LLVector3>& normalsp,
  657. LLStrider<LLVector2>& texcoordsp,
  658. LLStrider<LLColor4U>& colorsp,
  659. LLStrider<U16>& indicesp) = 0;
  660. F32 mDepth;
  661. };
  662. class LLStaticViewerObject : public LLViewerObject
  663. {
  664. public:
  665. LLStaticViewerObject(const LLUUID& id, const LLPCode pcode, LLViewerRegion* regionp, BOOL is_global = FALSE)
  666. : LLViewerObject(id,pcode,regionp, is_global)
  667. { }
  668. virtual void updateDrawable(BOOL force_damped);
  669. };
  670. #endif