diff options
| author | Andrey Kleshchev <andreykproductengine@lindenlab.com> | 2022-02-21 21:31:19 +0200 | 
|---|---|---|
| committer | Andrey Kleshchev <andreykproductengine@lindenlab.com> | 2022-02-21 21:31:19 +0200 | 
| commit | e24acd81e0cf47c1a8f39e2485daf81c39d26ca3 (patch) | |
| tree | 7130d4f19443eea3760210b11078f4c86c6212f7 /indra/newview | |
| parent | 97f6736d7fe2575023eff3a6429855c19d9f92f5 (diff) | |
SL-16892 Fix crash at getCameraOffsetInitial
getCameraOffsetInitial() call can happen before init()
Diffstat (limited to 'indra/newview')
| -rw-r--r-- | indra/newview/llagentcamera.cpp | 19 | ||||
| -rw-r--r-- | indra/newview/llagentcamera.h | 6 | 
2 files changed, 10 insertions, 15 deletions
| diff --git a/indra/newview/llagentcamera.cpp b/indra/newview/llagentcamera.cpp index ed6c3c307f..84a41113be 100644 --- a/indra/newview/llagentcamera.cpp +++ b/indra/newview/llagentcamera.cpp @@ -210,9 +210,6 @@ void LLAgentCamera::init()  	mCameraPreset = (ECameraPreset) gSavedSettings.getU32("CameraPresetType"); -	mCameraOffsetInitial = gSavedSettings.getControl("CameraOffsetRearView"); -	mFocusOffsetInitial = gSavedSettings.getControl("FocusOffsetRearView"); -  	mCameraCollidePlane.clearVec();  	mCurrentCameraDistance = getCameraOffsetInitial().magVec() * gSavedSettings.getF32("CameraOffsetScale");  	mTargetCameraDistance = mCurrentCameraDistance; @@ -1672,8 +1669,8 @@ LLVector3d LLAgentCamera::calcThirdPersonFocusOffset()  		agent_rot *= ((LLViewerObject*)(gAgentAvatarp->getParent()))->getRenderRotation();  	} -	focus_offset = convert_from_llsd<LLVector3d>(mFocusOffsetInitial->get(), TYPE_VEC3D, ""); -	return focus_offset * agent_rot; +    static LLCachedControl<LLVector3d> focus_offset_initial(gSavedSettings, "FocusOffsetRearView", LLVector3d()); +	return focus_offset_initial * agent_rot;  }  void LLAgentCamera::setupSitCamera() @@ -1810,8 +1807,9 @@ LLVector3d LLAgentCamera::calcCameraPositionTargetGlobal(BOOL *hit_limit)  		}  		else  		{ -			local_camera_offset = mCameraZoomFraction * getCameraOffsetInitial() * gSavedSettings.getF32("CameraOffsetScale"); -			 +            static LLCachedControl<F32> camera_offset_scale(gSavedSettings, "CameraOffsetScale"); +            local_camera_offset = mCameraZoomFraction * getCameraOffsetInitial() * camera_offset_scale; +  			// are we sitting down?  			if (isAgentAvatarValid() && gAgentAvatarp->getParent())  			{ @@ -2028,12 +2026,15 @@ bool LLAgentCamera::isJoystickCameraUsed()  LLVector3 LLAgentCamera::getCameraOffsetInitial()  { -	return convert_from_llsd<LLVector3>(mCameraOffsetInitial->get(), TYPE_VEC3, ""); +    // getCameraOffsetInitial and getFocusOffsetInitial can be called on update from idle before init() +    static LLCachedControl<LLVector3> camera_offset_initial (gSavedSettings, "CameraOffsetRearView", LLVector3()); +	return camera_offset_initial;  }  LLVector3d LLAgentCamera::getFocusOffsetInitial()  { -	return convert_from_llsd<LLVector3d>(mFocusOffsetInitial->get(), TYPE_VEC3D, ""); +    static LLCachedControl<LLVector3d> focus_offset_initial(gSavedSettings, "FocusOffsetRearView", LLVector3d()); +	return focus_offset_initial;  }  F32 LLAgentCamera::getCameraMaxZoomDistance() diff --git a/indra/newview/llagentcamera.h b/indra/newview/llagentcamera.h index ec1ed433d7..89680f95dc 100644 --- a/indra/newview/llagentcamera.h +++ b/indra/newview/llagentcamera.h @@ -131,12 +131,6 @@ private:  	/** Camera preset in Third Person Mode */  	ECameraPreset mCameraPreset;  -	/** Initial camera offset */ -	LLPointer<LLControlVariable> mCameraOffsetInitial; - -	/** Initial focus offset */ -	LLPointer<LLControlVariable> mFocusOffsetInitial; -  	LLQuaternion mInitSitRot;  	//-------------------------------------------------------------------- | 
