aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/llvotree.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'linden/indra/newview/llvotree.cpp')
-rw-r--r--linden/indra/newview/llvotree.cpp74
1 files changed, 58 insertions, 16 deletions
diff --git a/linden/indra/newview/llvotree.cpp b/linden/indra/newview/llvotree.cpp
index c86803d..23c92ea 100644
--- a/linden/indra/newview/llvotree.cpp
+++ b/linden/indra/newview/llvotree.cpp
@@ -4,7 +4,7 @@
4 * 4 *
5 * $LicenseInfo:firstyear=2002&license=viewergpl$ 5 * $LicenseInfo:firstyear=2002&license=viewergpl$
6 * 6 *
7 * Copyright (c) 2002-2008, Linden Research, Inc. 7 * Copyright (c) 2002-2009, Linden Research, Inc.
8 * 8 *
9 * Second Life Viewer Source Code 9 * Second Life Viewer Source Code
10 * The source code in this file ("Source Code") is provided by Linden Lab 10 * The source code in this file ("Source Code") is provided by Linden Lab
@@ -273,9 +273,9 @@ U32 LLVOTree::processUpdateMessage(LLMessageSystem *mesgsys,
273 // Do base class updates... 273 // Do base class updates...
274 U32 retval = LLViewerObject::processUpdateMessage(mesgsys, user_data, block_num, update_type, dp); 274 U32 retval = LLViewerObject::processUpdateMessage(mesgsys, user_data, block_num, update_type, dp);
275 275
276 if ( (getVelocity().magVecSquared() > 0.f) 276 if ( (getVelocity().lengthSquared() > 0.f)
277 ||(getAcceleration().magVecSquared() > 0.f) 277 ||(getAcceleration().lengthSquared() > 0.f)
278 ||(getAngularVelocity().magVecSquared() > 0.f)) 278 ||(getAngularVelocity().lengthSquared() > 0.f))
279 { 279 {
280 llinfos << "ACK! Moving tree!" << llendl; 280 llinfos << "ACK! Moving tree!" << llendl;
281 setVelocity(LLVector3::zero); 281 setVelocity(LLVector3::zero);
@@ -312,7 +312,7 @@ U32 LLVOTree::processUpdateMessage(LLMessageSystem *mesgsys,
312 mTreeImagep = gImageList.getImage(sSpeciesTable[mSpecies]->mTextureID); 312 mTreeImagep = gImageList.getImage(sSpeciesTable[mSpecies]->mTextureID);
313 if (mTreeImagep) 313 if (mTreeImagep)
314 { 314 {
315 mTreeImagep->bindTexture(0); 315 gGL.getTexUnit(0)->bind(mTreeImagep.get());
316 } 316 }
317 mBranchLength = sSpeciesTable[mSpecies]->mBranchLength; 317 mBranchLength = sSpeciesTable[mSpecies]->mBranchLength;
318 mTrunkLength = sSpeciesTable[mSpecies]->mTrunkLength; 318 mTrunkLength = sSpeciesTable[mSpecies]->mTrunkLength;
@@ -359,14 +359,14 @@ BOOL LLVOTree::idleUpdate(LLAgent &agent, LLWorld &world, const F64 &time)
359 mTrunkBend += mTrunkVel; 359 mTrunkBend += mTrunkVel;
360 mTrunkVel *= 0.99f; // Add damping 360 mTrunkVel *= 0.99f; // Add damping
361 361
362 if (mTrunkBend.magVec() > 1.f) 362 if (mTrunkBend.length() > 1.f)
363 { 363 {
364 mTrunkBend.normVec(); 364 mTrunkBend.normalize();
365 } 365 }
366 366
367 if (mTrunkVel.magVec() > 1.f) 367 if (mTrunkVel.length() > 1.f)
368 { 368 {
369 mTrunkVel.normVec(); 369 mTrunkVel.normalize();
370 } 370 }
371 371
372 return TRUE; 372 return TRUE;
@@ -391,7 +391,7 @@ void LLVOTree::setPixelAreaAndAngle(LLAgent &agent)
391 391
392 // This should be the camera's center, as soon as we move to all region-local. 392 // This should be the camera's center, as soon as we move to all region-local.
393 LLVector3 relative_position = getPositionAgent() - agent.getCameraPositionAgent(); 393 LLVector3 relative_position = getPositionAgent() - agent.getCameraPositionAgent();
394 F32 range = relative_position.magVec(); // ugh, square root 394 F32 range = relative_position.length(); // ugh, square root
395 395
396 F32 max_scale = mBillboardScale * getMaxScale(); 396 F32 max_scale = mBillboardScale * getMaxScale();
397 F32 area = max_scale * (max_scale*mBillboardRatio); 397 F32 area = max_scale * (max_scale*mBillboardRatio);
@@ -713,9 +713,9 @@ BOOL LLVOTree::updateGeometry(LLDrawable *drawable)
713 LLVector2 tc; 713 LLVector2 tc;
714 // This isn't totally accurate. Should compute based on slope as well. 714 // This isn't totally accurate. Should compute based on slope as well.
715 start_radius = r0 * (1.f + 1.2f*fabs(z - 0.66f*height)/height); 715 start_radius = r0 * (1.f + 1.2f*fabs(z - 0.66f*height)/height);
716 nvec.setVec( cos(nangle * DEG_TO_RAD)*start_radius*nvec_scale, 716 nvec.set( cos(nangle * DEG_TO_RAD)*start_radius*nvec_scale,
717 sin(nangle * DEG_TO_RAD)*start_radius*nvec_scale, 717 sin(nangle * DEG_TO_RAD)*start_radius*nvec_scale,
718 z*nvec_scalez); 718 z*nvec_scalez);
719 // First and last slice at 0 radius (to bring in top/bottom of structure) 719 // First and last slice at 0 radius (to bring in top/bottom of structure)
720 radius = start_radius + turbulence3((F32*)&nvec.mV, (F32)fractal_depth)*noise_scale; 720 radius = start_radius + turbulence3((F32*)&nvec.mV, (F32)fractal_depth)*noise_scale;
721 721
@@ -918,7 +918,7 @@ void LLVOTree::updateRadius()
918 918
919void LLVOTree::updateSpatialExtents(LLVector3& newMin, LLVector3& newMax) 919void LLVOTree::updateSpatialExtents(LLVector3& newMin, LLVector3& newMax)
920{ 920{
921 F32 radius = getScale().magVec()*0.05f; 921 F32 radius = getScale().length()*0.05f;
922 LLVector3 center = getRenderPosition(); 922 LLVector3 center = getRenderPosition();
923 923
924 F32 sz = mBillboardScale*mBillboardRatio*radius*0.5f; 924 F32 sz = mBillboardScale*mBillboardRatio*radius*0.5f;
@@ -926,11 +926,53 @@ void LLVOTree::updateSpatialExtents(LLVector3& newMin, LLVector3& newMax)
926 926
927 center += LLVector3(0, 0, size.mV[2]) * getRotation(); 927 center += LLVector3(0, 0, size.mV[2]) * getRotation();
928 928
929 newMin.setVec(center-size); 929 newMin.set(center-size);
930 newMax.setVec(center+size); 930 newMax.set(center+size);
931 mDrawable->setPositionGroup(center); 931 mDrawable->setPositionGroup(center);
932} 932}
933 933
934BOOL LLVOTree::lineSegmentIntersect(const LLVector3& start, const LLVector3& end, S32 face, BOOL pick_transparent, S32 *face_hitp,
935 LLVector3* intersection,LLVector2* tex_coord, LLVector3* normal, LLVector3* bi_normal)
936
937{
938
939 if (!lineSegmentBoundingBox(start, end))
940 {
941 return FALSE;
942 }
943
944 const LLVector3* ext = mDrawable->getSpatialExtents();
945
946 LLVector3 center = (ext[1]+ext[0])*0.5f;
947 LLVector3 size = (ext[1]-ext[0]);
948
949 LLQuaternion quat = getRotation();
950
951 center -= LLVector3(0,0,size.magVec() * 0.25f)*quat;
952
953 size.scaleVec(LLVector3(0.25f, 0.25f, 1.f));
954 size.mV[0] = llmin(size.mV[0], 1.f);
955 size.mV[1] = llmin(size.mV[1], 1.f);
956
957 LLVector3 pos, norm;
958
959 if (linesegment_tetrahedron(start, end, center, size, quat, pos, norm))
960 {
961 if (intersection)
962 {
963 *intersection = pos;
964 }
965
966 if (normal)
967 {
968 *normal = norm;
969 }
970 return TRUE;
971 }
972
973 return FALSE;
974}
975
934U32 LLVOTree::getPartitionType() const 976U32 LLVOTree::getPartitionType() const
935{ 977{
936 return LLViewerRegion::PARTITION_TREE; 978 return LLViewerRegion::PARTITION_TREE;