PageRenderTime 129ms CodeModel.GetById 32ms app.highlight 78ms RepoModel.GetById 1ms app.codeStats 8ms

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