PageRenderTime 70ms CodeModel.GetById 2ms app.highlight 60ms RepoModel.GetById 1ms app.codeStats 0ms

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