[Bf-blender-cvs] [ddf5800] master: BGE: LoD Hysteresis clean up

Jorge Bernal noreply at git.blender.org
Mon Mar 23 19:05:29 CET 2015


Commit: ddf58004c4a4ad7fc59f9cd1c3f6f0a800424ee3
Author: Jorge Bernal
Date:   Mon Mar 23 18:57:19 2015 +0100
Branches: master
https://developer.blender.org/rBddf58004c4a4ad7fc59f9cd1c3f6f0a800424ee3

BGE: LoD Hysteresis clean up

Move scene hysteresis value to KX_Scene where it should be (instead of
KX_GameObject)

===================================================================

M	source/gameengine/Converter/BL_BlenderDataConversion.cpp
M	source/gameengine/Ketsji/KX_GameObject.cpp
M	source/gameengine/Ketsji/KX_GameObject.h
M	source/gameengine/Ketsji/KX_Scene.cpp
M	source/gameengine/Ketsji/KX_Scene.h

===================================================================

diff --git a/source/gameengine/Converter/BL_BlenderDataConversion.cpp b/source/gameengine/Converter/BL_BlenderDataConversion.cpp
index 7b5cc45..6e3a321 100644
--- a/source/gameengine/Converter/BL_BlenderDataConversion.cpp
+++ b/source/gameengine/Converter/BL_BlenderDataConversion.cpp
@@ -1556,7 +1556,7 @@ static KX_GameObject *gameobject_from_blenderobject(
 			}
 			if (blenderscene->gm.lodflag & SCE_LOD_USE_HYST) {
 				kxscene->SetLodHysteresis(true);
-				gameobj->SetLodHysteresisValue(blenderscene->gm.scehysteresis);
+				kxscene->SetLodHysteresisValue(blenderscene->gm.scehysteresis);
 			}
 		}
 	
diff --git a/source/gameengine/Ketsji/KX_GameObject.cpp b/source/gameengine/Ketsji/KX_GameObject.cpp
index 16dfe5b..d0c6792 100644
--- a/source/gameengine/Ketsji/KX_GameObject.cpp
+++ b/source/gameengine/Ketsji/KX_GameObject.cpp
@@ -93,7 +93,6 @@ KX_GameObject::KX_GameObject(
       m_layer(0),
       m_currentLodLevel(0),
       m_previousLodLevel(0),
-      m_lodHysteresis(0),
       m_pBlenderObject(NULL),
       m_pBlenderGroupObject(NULL),
       m_bSuspendDynamics(false),
@@ -786,11 +785,6 @@ void KX_GameObject::AddLodMesh(RAS_MeshObject* mesh)
 	m_lodmeshes.push_back(mesh);
 }
 
-void KX_GameObject::SetLodHysteresisValue(int hysteresis)
-{
-	m_lodHysteresis = hysteresis;
-}
-
 void KX_GameObject::UpdateLod(MT_Vector3 &cam_pos)
 {
 	// Handle dupligroups
@@ -811,20 +805,20 @@ void KX_GameObject::UpdateLod(MT_Vector3 &cam_pos)
 	int level = 0;
 	Object *bob = this->GetBlenderObject();
 	LodLevel *lod = (LodLevel*) bob->lodlevels.first;
-	KX_Scene *sce = this->GetScene();
+	KX_Scene *kxscene = this->GetScene();
 
 	for (; lod; lod = lod->next, level++) {
 		if (!lod->source || lod->source->type != OB_MESH) level--;
 		if (!lod->next) break;
 		if (level == (this->m_previousLodLevel) || (level == (this->m_previousLodLevel + 1))) {
 			short hysteresis = 0;
-			if (sce->IsActivedLodHysteresis()) {
+			if (kxscene->IsActivedLodHysteresis()) {
 				// if exists, LoD level hysteresis will override scene hysteresis
 				if (lod->next->flags & OB_LOD_USE_HYST) {
 					hysteresis = lod->next->obhysteresis;
 				}
-				else if (this->m_lodHysteresis != 0) {
-					hysteresis = m_lodHysteresis;
+				else {
+					hysteresis = kxscene->GetLodHysteresisValue();
 				}
 			}
 			float hystvariance = MT_abs(lod->next->distance - lod->distance) * hysteresis / 100;
@@ -833,13 +827,13 @@ void KX_GameObject::UpdateLod(MT_Vector3 &cam_pos)
 		}
 		else if (level == (this->m_previousLodLevel - 1)) {
 			short hysteresis = 0;
-			if (sce->IsActivedLodHysteresis()) {
+			if (kxscene->IsActivedLodHysteresis()) {
 				// if exists, LoD level hysteresis will override scene hysteresis
 				if (lod->next->flags & OB_LOD_USE_HYST) {
 					hysteresis = lod->next->obhysteresis;
 				}
-				else if (this->m_lodHysteresis != 0) {
-					hysteresis = m_lodHysteresis;
+				else {
+					hysteresis = kxscene->GetLodHysteresisValue();
 				}
 			}
 			float hystvariance = MT_abs(lod->next->distance - lod->distance) * hysteresis / 100;
diff --git a/source/gameengine/Ketsji/KX_GameObject.h b/source/gameengine/Ketsji/KX_GameObject.h
index d9810b8..acc6358 100644
--- a/source/gameengine/Ketsji/KX_GameObject.h
+++ b/source/gameengine/Ketsji/KX_GameObject.h
@@ -91,7 +91,6 @@ protected:
 	std::vector<RAS_MeshObject*>		m_lodmeshes;
 	int                                 m_currentLodLevel;
 	short								m_previousLodLevel;
-	int									m_lodHysteresis;
 	SG_QList							m_meshSlots;	// head of mesh slots of this 
 	struct Object*						m_pBlenderObject;
 	struct Object*						m_pBlenderGroupObject;
@@ -807,14 +806,6 @@ public:
 	);
 
 	/**
-	 * Set lod hysteresis value
-	 */
-		void
-	SetLodHysteresisValue(
-		int hysteresis
-	);
-
-	/**
 	 * Updates the current lod level based on distance from camera.
 	 */
 		void
diff --git a/source/gameengine/Ketsji/KX_Scene.cpp b/source/gameengine/Ketsji/KX_Scene.cpp
index d9d07e7..e26fdaa 100644
--- a/source/gameengine/Ketsji/KX_Scene.cpp
+++ b/source/gameengine/Ketsji/KX_Scene.cpp
@@ -157,7 +157,8 @@ KX_Scene::KX_Scene(class SCA_IInputDevice* keyboarddevice,
 	m_active_camera(NULL),
 	m_ueberExecutionPriority(0),
 	m_blenderScene(scene),
-	m_isActivedHysteresis(false)
+	m_isActivedHysteresis(false),
+	m_lodHysteresisValue(0)
 {
 	m_suspendedtime = 0.0;
 	m_suspendeddelta = 0.0;
@@ -1774,6 +1775,16 @@ bool KX_Scene::IsActivedLodHysteresis(void)
 	return m_isActivedHysteresis;
 }
 
+void KX_Scene::SetLodHysteresisValue(int hysteresisvalue)
+{
+	m_lodHysteresisValue = hysteresisvalue;
+}
+
+int KX_Scene::GetLodHysteresisValue(void)
+{
+	return m_lodHysteresisValue;
+}
+
 void KX_Scene::UpdateObjectActivity(void) 
 {
 	if (m_activity_culling) {
diff --git a/source/gameengine/Ketsji/KX_Scene.h b/source/gameengine/Ketsji/KX_Scene.h
index 19873da..a031be7 100644
--- a/source/gameengine/Ketsji/KX_Scene.h
+++ b/source/gameengine/Ketsji/KX_Scene.h
@@ -296,9 +296,10 @@ protected:
 	KX_ObstacleSimulation* m_obstacleSimulation;
 
 	/**
-	 * Does this scene active the LoD Hysteresis?
+	 * LOD Hysteresis settings
 	 */
 	bool m_isActivedHysteresis;
+	int m_lodHysteresisValue;
 
 public:
 	KX_Scene(class SCA_IInputDevice* keyboarddevice,
@@ -552,9 +553,11 @@ public:
 	// Update the mesh for objects based on level of detail settings
 	void UpdateObjectLods(void);
 
-	// Enable/disable LoD Hysteresis
+	// LoD Hysteresis functions
 	void SetLodHysteresis(bool active);
 	bool IsActivedLodHysteresis();
+	void SetLodHysteresisValue(int hysteresisvalue);
+	int GetLodHysteresisValue();
 	
 	// Update the activity box settings for objects in this scene, if needed.
 	void UpdateObjectActivity(void);




More information about the Bf-blender-cvs mailing list