diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index 537a22a41..62c638440 100644 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -1739,6 +1739,17 @@ Value 2 + AvatarPhysics + + Comment + Enable avatar wearable physics. + Persist + 1 + Type + Boolean + Value + 1 + AvatarSex Comment @@ -8842,6 +8853,17 @@ Value 35 + RenderAvatarPhysicsLODFactor + + Comment + Controls level of detail of avatar physics (such as breast physics). + Persist + 1 + Type + F32 + Value + 1.0 + RenderAvatarInvisible Comment diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index 39eba7877..38ae9202e 100644 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -429,6 +429,7 @@ static void settings_to_globals() LLVolumeImplFlexible::sUpdateFactor = gSavedSettings.getF32("RenderFlexTimeFactor"); LLVOTree::sTreeFactor = gSavedSettings.getF32("RenderTreeLODFactor"); LLVOAvatar::sLODFactor = gSavedSettings.getF32("RenderAvatarLODFactor"); + LLVOAvatar::sPhysicsLODFactor = gSavedSettings.getF32("RenderAvatarPhysicsLODFactor"); LLVOAvatar::sMaxVisible = gSavedSettings.getS32("RenderAvatarMaxVisible"); LLVOAvatar::sVisibleInFirstPerson = gSavedSettings.getBOOL("FirstPersonAvatarVisible"); // clamp auto-open time to some minimum usable value diff --git a/indra/newview/llphysicsmotion.cpp b/indra/newview/llphysicsmotion.cpp index 59434a1f1..475e153c5 100644 --- a/indra/newview/llphysicsmotion.cpp +++ b/indra/newview/llphysicsmotion.cpp @@ -111,12 +111,14 @@ public: ~LLPhysicsMotion() {} - BOOL onUpdate(F32 time, bool &bHandled); + BOOL onUpdate(F32 time); LLPointer getJointState() { return mJointState; } + + void reset(); protected: F32 getParamValue(const std::string& controller_key) { @@ -135,6 +137,7 @@ protected: F32 toLocal(const LLVector3 &world); F32 calculateVelocity_local(); F32 calculateAcceleration_local(F32 velocity_local); + private: const std::string mParamDriverName; const std::string mParamControllerName; @@ -193,7 +196,8 @@ BOOL LLPhysicsMotion::initialize() LLPhysicsMotionController::LLPhysicsMotionController(const LLUUID &id) : LLMotion(id), - mCharacter(NULL) + mCharacter(NULL), + mIsDefault(true) { mName = "breast_motion"; } @@ -210,11 +214,13 @@ LLPhysicsMotionController::~LLPhysicsMotionController() BOOL LLPhysicsMotionController::onActivate() { + llinfos << "LLPhysicsMotionController activate" << llendl; return TRUE; } void LLPhysicsMotionController::onDeactivate() { + llinfos << "LLPhysicsMotionController deactivate" << llendl; } LLMotion::LLMotionInitStatus LLPhysicsMotionController::onInitialize(LLCharacter *character) @@ -414,36 +420,42 @@ F32 LLPhysicsMotion::calculateAcceleration_local(const F32 velocity_local) BOOL LLPhysicsMotionController::onUpdate(F32 time, U8* joint_mask) { // Skip if disabled globally. - /*if (!gSavedSettings.getBOOL("AvatarPhysics")) + static const LLCachedControl avatar_physics("AvatarPhysics",false); + if (!avatar_physics || (!((LLVOAvatar*)mCharacter)->isSelf() && !((LLVOAvatar*)mCharacter)->mSupportsPhysics)) { - return TRUE; - }*/ + if(!mIsDefault) + { + mIsDefault = true; + for (motion_vec_t::iterator iter = mMotions.begin();iter != mMotions.end();++iter) + { + (*iter)->reset(); + } + mCharacter->updateVisualParams(); + } + ((LLVOAvatar*)mCharacter)->idleUpdateBoobEffect(); //Fall back to emerald physics + return TRUE; + } + mIsDefault = false; + BOOL update_visuals = FALSE; - bool physics_handled = false; for (motion_vec_t::iterator iter = mMotions.begin(); iter != mMotions.end(); ++iter) { LLPhysicsMotion *motion = (*iter); - bool bHandled; - update_visuals |= motion->onUpdate(time,bHandled); - physics_handled |= bHandled; + update_visuals |= motion->onUpdate(time); } if (update_visuals) mCharacter->updateVisualParams(); - if(!physics_handled && mCharacter) //If absolutely nothing was done, and it wasn't due to timers/lod - ((LLVOAvatar*)mCharacter)->idleUpdateBoobEffect(); return TRUE; } - // Return TRUE if character has to update visual params. -BOOL LLPhysicsMotion::onUpdate(F32 time, bool &bHandled) +BOOL LLPhysicsMotion::onUpdate(F32 time) { - bHandled = false; // static FILE *mFileWrite = fopen("c:\\temp\\avatar_data.txt","w"); if (!mParamDriver) @@ -461,7 +473,6 @@ BOOL LLPhysicsMotion::onUpdate(F32 time, bool &bHandled) const F32 time_delta = time - mLastTime; - bHandled = true; // Don't update too frequently, to avoid precision errors from small time slices. if (time_delta <= .01) { @@ -540,7 +551,6 @@ BOOL LLPhysicsMotion::onUpdate(F32 time, bool &bHandled) // to set the position to the default (i.e. user) position. if ((behavior_maxeffect == 0) && (position_current_local == position_user_local)) { - bHandled = false; //Let emerald boob stuff do its thing, possibly. return update_visuals; } @@ -745,3 +755,21 @@ void LLPhysicsMotion::setParamValue(LLViewerVisualParam *param, new_value_local, FALSE); } + +void LLPhysicsMotion::reset() +{ + LLDriverParam *driver_param = dynamic_cast(mParamDriver); + if (driver_param) + { + if ((driver_param->getGroup() != VISUAL_PARAM_GROUP_TWEAKABLE) && + (driver_param->getGroup() != VISUAL_PARAM_GROUP_TWEAKABLE_NO_TRANSMIT)) + { + mCharacter->setVisualParamWeight(driver_param,driver_param->getDefaultWeight()); + } + for (LLDriverParam::entry_list_t::iterator iter = driver_param->mDriven.begin(); + iter != driver_param->mDriven.end();++iter) + { + mCharacter->setVisualParamWeight((*iter).mParam,(*iter).mParam->getDefaultWeight()); + } + } +} \ No newline at end of file diff --git a/indra/newview/llphysicsmotion.h b/indra/newview/llphysicsmotion.h index 657698e4f..3ee44f8d5 100644 --- a/indra/newview/llphysicsmotion.h +++ b/indra/newview/llphysicsmotion.h @@ -110,7 +110,6 @@ public: virtual void onDeactivate(); LLCharacter* getCharacter() { return mCharacter; } - protected: void addMotion(LLPhysicsMotion *motion); private: @@ -118,6 +117,8 @@ private: typedef std::vector motion_vec_t; motion_vec_t mMotions; + + bool mIsDefault; }; #endif // LL_LLPHYSICSMOTION_H diff --git a/indra/newview/llviewercontrol.cpp b/indra/newview/llviewercontrol.cpp index 8af25724f..22609c938 100644 --- a/indra/newview/llviewercontrol.cpp +++ b/indra/newview/llviewercontrol.cpp @@ -216,6 +216,12 @@ static bool handleAvatarLODChanged(const LLSD& newvalue) return true; } +static bool handleAvatarPhysicsLODChanged(const LLSD& newvalue) +{ + LLVOAvatar::sLODFactor = (F32) newvalue.asReal(); + return true; +} + static bool handleAvatarMaxVisibleChanged(const LLSD& newvalue) { LLVOAvatar::sMaxVisible = (U32) newvalue.asInteger(); @@ -583,6 +589,7 @@ void settings_setup_listeners() gSavedSettings.getControl("RenderAvatarLODFactor")->getSignal()->connect(boost::bind(&handleAvatarLODChanged, _1)); gSavedSettings.getControl("RenderTerrainLODFactor")->getSignal()->connect(boost::bind(&handleTerrainLODChanged, _1)); gSavedSettings.getControl("RenderTreeLODFactor")->getSignal()->connect(boost::bind(&handleTreeLODChanged, _1)); + gSavedSettings.getControl("RenderAvatarPhysicsLODFactor")->getSignal()->connect(boost::bind(&handleAvatarPhysicsLODChanged, _1)); gSavedSettings.getControl("RenderFlexTimeFactor")->getSignal()->connect(boost::bind(&handleFlexLODChanged, _1)); gSavedSettings.getControl("ThrottleBandwidthKBPS")->getSignal()->connect(boost::bind(&handleBandwidthChanged, _1)); gSavedSettings.getControl("RenderGamma")->getSignal()->connect(boost::bind(&handleGammaChanged, _1)); diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp index c1d9f11a9..9624a2151 100644 --- a/indra/newview/llvoavatar.cpp +++ b/indra/newview/llvoavatar.cpp @@ -795,7 +795,8 @@ LLVOAvatar::LLVOAvatar(const LLUUID& id, mFullyLoadedInitialized(FALSE), mHasBakedHair( FALSE ), mSupportsAlphaLayers(FALSE), - mFirstSetActualBoobGravRan( false ) + mFirstSetActualBoobGravRan( false ), + mSupportsPhysics( false ) //mFirstSetActualButtGravRan( false ), //mFirstSetActualFatGravRan( false ) // @@ -9368,6 +9369,8 @@ void LLVOAvatar::processAvatarAppearance( LLMessageSystem* mesgsys ) updateMeshTextures(); // enables updates for laysets without baked textures. + mSupportsPhysics = false; + // parse visual params S32 num_blocks = mesgsys->getNumberOfBlocksFast(_PREHASH_VisualParam); if( num_blocks > 1 ) @@ -9400,6 +9403,10 @@ void LLVOAvatar::processAvatarAppearance( LLMessageSystem* mesgsys ) mesgsys->getU8Fast(_PREHASH_VisualParam, _PREHASH_ParamValue, value, i); F32 newWeight = U8_to_F32(value, param->getMinWeight(), param->getMaxWeight()); + if(param->getID() == 10000) + { + mSupportsPhysics = true; + } if(param->getID() == 507 && newWeight != getActualBoobGrav()) { llwarns << "Boob Grav SET to " << newWeight << " for " << getFullname() << llendl; @@ -9444,6 +9451,8 @@ void LLVOAvatar::processAvatarAppearance( LLMessageSystem* mesgsys ) { if (param->getName() == "tattoo_red") llinfos << getFullname() << " does not have tattoo tinting." << llendl; + else if(param->getName() == "breast_physics_leftright_spring") + llinfos << getFullname() << " does not have avatar physics." << llendl; else llwarns << "Number of params in AvatarAppearance msg does not match number of params in avatar xml file for " << getFullname() << " (Prematurely reached end of list at " << param->getName() << ")." << llendl; //return; //ASC-TTRFE diff --git a/indra/newview/llvoavatar.h b/indra/newview/llvoavatar.h index 0ea151b12..e21337c90 100644 --- a/indra/newview/llvoavatar.h +++ b/indra/newview/llvoavatar.h @@ -99,6 +99,9 @@ public: void getClientInfo(std::string& clientTag, LLColor4& tagColor, BOOL useComment=FALSE); std::string extraMetadata; // + + // EmeraldBoobUtils + bool mSupportsPhysics; //Client supports v2 wearable physics. Disable emerald physics. //-------------------------------------------------------------------- // LLViewerObject interface