[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [20047] trunk/blender/source/gameengine: BGE performance: use inline function as much as possible in scenegraph and logic to avoid function call .

Benoit Bolsee benoit.bolsee at online.be
Sun May 3 23:51:57 CEST 2009


Revision: 20047
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=20047
Author:   ben2610
Date:     2009-05-03 23:51:57 +0200 (Sun, 03 May 2009)

Log Message:
-----------
BGE performance: use inline function as much as possible in scenegraph and logic to avoid function call.

Modified Paths:
--------------
    trunk/blender/source/gameengine/Expressions/Value.cpp
    trunk/blender/source/gameengine/Expressions/Value.h
    trunk/blender/source/gameengine/GameLogic/SCA_IActuator.cpp
    trunk/blender/source/gameengine/GameLogic/SCA_IActuator.h
    trunk/blender/source/gameengine/GameLogic/SCA_ILogicBrick.cpp
    trunk/blender/source/gameengine/GameLogic/SCA_ILogicBrick.h
    trunk/blender/source/gameengine/GameLogic/SCA_IObject.cpp
    trunk/blender/source/gameengine/GameLogic/SCA_IObject.h
    trunk/blender/source/gameengine/Ketsji/KX_GameObject.h

Modified: trunk/blender/source/gameengine/Expressions/Value.cpp
===================================================================
--- trunk/blender/source/gameengine/Expressions/Value.cpp	2009-05-03 21:42:39 UTC (rev 20046)
+++ trunk/blender/source/gameengine/Expressions/Value.cpp	2009-05-03 21:51:57 UTC (rev 20047)
@@ -453,53 +453,15 @@
 /*---------------------------------------------------------------------------------------------------------------------
 	Reference Counting
 ---------------------------------------------------------------------------------------------------------------------*/
-//
-// Add a reference to this value
-//
-CValue *CValue::AddRef()
-{
-	// Increase global reference count, used to see at the end of the program
-	// if all CValue-derived classes have been dereferenced to 0
-	//debug(gRefCountValue++);
-#ifdef _DEBUG
-	//gRefCountValue++;
-#endif
-	m_refcount++; 
-	return this;
-}
 
 
 
 //
 // Release a reference to this value (when reference count reaches 0, the value is removed from the heap)
 //
-int	CValue::Release()
-{
-	// Decrease global reference count, used to see at the end of the program
-	// if all CValue-derived classes have been dereferenced to 0
-	//debug(gRefCountValue--);
-#ifdef _DEBUG
-	//gRefCountValue--;
-#endif
-	// Decrease local reference count, if it reaches 0 the object should be freed
-	if (--m_refcount > 0)
-	{
-		// Reference count normal, return new reference count
-		return m_refcount;
-	}
-	else
-	{
-		// Reference count reached 0, delete ourselves and return 0
-//		MT_assert(m_refcount==0, "Reference count reached sub-zero, object released too much");
-		
-		delete this;
-		return 0;
-	}
 
-}
 
 
-
 //
 // Disable reference counting for this value
 //

Modified: trunk/blender/source/gameengine/Expressions/Value.h
===================================================================
--- trunk/blender/source/gameengine/Expressions/Value.h	2009-05-03 21:42:39 UTC (rev 20046)
+++ trunk/blender/source/gameengine/Expressions/Value.h	2009-05-03 21:51:57 UTC (rev 20047)
@@ -259,11 +259,50 @@
 	};
 
 	/// Reference Counting
-	int					GetRefCount()											{ return m_refcount; }
-	virtual	CValue*		AddRef();												// Add a reference to this value
-	virtual int			Release();												// Release a reference to this value (when reference count reaches 0, the value is removed from the heap)
-	
+	int					GetRefCount()											
+	{ 
+		return m_refcount; 
+	}
 
+	// Add a reference to this value
+	CValue*				AddRef()												
+	{
+		// Increase global reference count, used to see at the end of the program
+		// if all CValue-derived classes have been dereferenced to 0
+		//debug(gRefCountValue++);
+	#ifdef _DEBUG
+		//gRefCountValue++;
+	#endif
+		m_refcount++; 
+		return this;
+	}
+
+	// Release a reference to this value (when reference count reaches 0, the value is removed from the heap)
+	int			Release()								
+	{
+		// Decrease global reference count, used to see at the end of the program
+		// if all CValue-derived classes have been dereferenced to 0
+		//debug(gRefCountValue--);
+	#ifdef _DEBUG
+		//gRefCountValue--;
+	#endif
+		// Decrease local reference count, if it reaches 0 the object should be freed
+		if (--m_refcount > 0)
+		{
+			// Reference count normal, return new reference count
+			return m_refcount;
+		}
+		else
+		{
+			// Reference count reached 0, delete ourselves and return 0
+	//		MT_assert(m_refcount==0, "Reference count reached sub-zero, object released too much");
+			
+			delete this;
+			return 0;
+		}
+	}
+
+
 	/// Property Management
 	virtual void		SetProperty(const STR_String& name,CValue* ioProperty);						// Set property <ioProperty>, overwrites and releases a previous property with the same name if needed
 	virtual void		SetProperty(const char* name,CValue* ioProperty);

Modified: trunk/blender/source/gameengine/GameLogic/SCA_IActuator.cpp
===================================================================
--- trunk/blender/source/gameengine/GameLogic/SCA_IActuator.cpp	2009-05-03 21:42:39 UTC (rev 20046)
+++ trunk/blender/source/gameengine/GameLogic/SCA_IActuator.cpp	2009-05-03 21:51:57 UTC (rev 20047)
@@ -44,13 +44,6 @@
 
 
 
-void SCA_IActuator::AddEvent(CValue* event)
-{
-	m_events.push_back(event);
-}
-
-
-
 void SCA_IActuator::RemoveAllEvents()
 {	// remove event queue!
 	for (vector<CValue*>::iterator i=m_events.begin(); !(i==m_events.end());i++)

Modified: trunk/blender/source/gameengine/GameLogic/SCA_IActuator.h
===================================================================
--- trunk/blender/source/gameengine/GameLogic/SCA_IActuator.h	2009-05-03 21:42:39 UTC (rev 20046)
+++ trunk/blender/source/gameengine/GameLogic/SCA_IActuator.h	2009-05-03 21:51:57 UTC (rev 20047)
@@ -75,7 +75,11 @@
 	/** 
 	 * Add an event to an actuator.
 	 */ 
-	void AddEvent(CValue* event);
+	void AddEvent(CValue* event)
+	{
+		m_events.push_back(event);
+	}
+
 	virtual void ProcessReplica();
 
 	/** 

Modified: trunk/blender/source/gameengine/GameLogic/SCA_ILogicBrick.cpp
===================================================================
--- trunk/blender/source/gameengine/GameLogic/SCA_ILogicBrick.cpp	2009-05-03 21:42:39 UTC (rev 20046)
+++ trunk/blender/source/gameengine/GameLogic/SCA_ILogicBrick.cpp	2009-05-03 21:51:57 UTC (rev 20047)
@@ -71,13 +71,6 @@
 
 
 
-SCA_IObject* SCA_ILogicBrick::GetParent()
-{
-	return m_gameobj;
-}
-
-
-
 void SCA_ILogicBrick::ReParent(SCA_IObject* parent)
 {
 	m_gameobj = parent;
@@ -142,14 +135,6 @@
 	m_name = name;
 }
 
-
-bool SCA_ILogicBrick::IsActive()
-{
-	return m_bActive;
-}
-
-
-
 bool SCA_ILogicBrick::LessComparedTo(SCA_ILogicBrick* other)
 {
 	return (this->m_Execute_Ueber_Priority < other->m_Execute_Ueber_Priority) 
@@ -157,22 +142,6 @@
 		(this->m_Execute_Priority < other->m_Execute_Priority));
 }
 
-
-
-void SCA_ILogicBrick::SetActive(bool active)
-{
-	m_bActive=active;
-	if (active)
-	{
-		//m_gameobj->SetDebugColor(GetDrawColor());
-	} else
-	{
-		//m_gameobj->ResetDebugColor();
-	}
-}
-
-
-
 void SCA_ILogicBrick::RegisterEvent(CValue* eventval)
 {
 	if (m_eventval)

Modified: trunk/blender/source/gameengine/GameLogic/SCA_ILogicBrick.h
===================================================================
--- trunk/blender/source/gameengine/GameLogic/SCA_ILogicBrick.h	2009-05-03 21:42:39 UTC (rev 20046)
+++ trunk/blender/source/gameengine/GameLogic/SCA_ILogicBrick.h	2009-05-03 21:51:57 UTC (rev 20047)
@@ -59,7 +59,8 @@
 	void SetExecutePriority(int execute_Priority);
 	void SetUeberExecutePriority(int execute_Priority);
 
-	SCA_IObject*	GetParent();
+	SCA_IObject*	GetParent() { return m_gameobj; }
+
 	virtual void	ReParent(SCA_IObject* parent);
 	virtual void	Relink(GEN_Map<GEN_HashedPtr, void*> *obj_map);
 	virtual void Delete() { Release(); }
@@ -73,9 +74,17 @@
 	virtual STR_String	GetName();
 	virtual void		SetName(STR_String name);
 		
-	bool				IsActive();
-	void				SetActive(bool active) ;
+	bool				IsActive()
+	{
+		return m_bActive;
+	}
 
+	void				SetActive(bool active)
+	{
+		m_bActive=active;
+	}
+
+
 	virtual	bool		LessComparedTo(SCA_ILogicBrick* other);
 	
 	virtual PyObject* py_getattro(PyObject *attr);

Modified: trunk/blender/source/gameengine/GameLogic/SCA_IObject.cpp
===================================================================
--- trunk/blender/source/gameengine/GameLogic/SCA_IObject.cpp	2009-05-03 21:42:39 UTC (rev 20046)
+++ trunk/blender/source/gameengine/GameLogic/SCA_IObject.cpp	2009-05-03 21:51:57 UTC (rev 20047)
@@ -79,29 +79,6 @@
 	//}
 }
 
-
-
-SCA_ControllerList& SCA_IObject::GetControllers()
-{
-	return m_controllers;
-}
-
-
-
-SCA_SensorList& SCA_IObject::GetSensors()
-{
-	return m_sensors;
-}
-
-
-
-SCA_ActuatorList& SCA_IObject::GetActuators()
-{
-	return m_actuators;
-}
-
-
-
 void SCA_IObject::AddSensor(SCA_ISensor* act)
 {
 	act->AddRef();
@@ -143,20 +120,6 @@
 	}
 }
 
-void SCA_IObject::SetIgnoreActivityCulling(bool b)
-{
-	m_ignore_activity_culling = b;
-}
-
-
-
-bool SCA_IObject::GetIgnoreActivityCulling()
-{
-	return m_ignore_activity_culling;
-}
-
-
-
 void SCA_IObject::ReParentLogic()
 {
 	SCA_ActuatorList& oldactuators  = GetActuators();
@@ -256,14 +219,6 @@
 
 
 
-void SCA_IObject::SetCurrentTime(float currentTime) {
-	//T_InterpolatorList::iterator i;
-	//for (i = m_interpolators.begin(); !(i == m_interpolators.end()); ++i) {
-	//	(*i)->Execute(currentTime);
-	//}
-}
-	
-
 #if 0
 const MT_Point3& SCA_IObject::ConvertPythonPylist(PyObject* pylist)
 {

Modified: trunk/blender/source/gameengine/GameLogic/SCA_IObject.h
===================================================================
--- trunk/blender/source/gameengine/GameLogic/SCA_IObject.h	2009-05-03 21:42:39 UTC (rev 20046)
+++ trunk/blender/source/gameengine/GameLogic/SCA_IObject.h	2009-05-03 21:51:57 UTC (rev 20047)
@@ -83,9 +83,18 @@
 	SCA_IObject(PyTypeObject* T=&Type);
 	virtual ~SCA_IObject();
 
-	SCA_ControllerList& GetControllers();
-	SCA_SensorList& GetSensors();
-	SCA_ActuatorList& GetActuators();
+	SCA_ControllerList& GetControllers()
+	{
+		return m_controllers;
+	}
+	SCA_SensorList& GetSensors()
+	{
+		return m_sensors;
+	}
+	SCA_ActuatorList& GetActuators()
+	{
+		return m_actuators;
+	}
 
 	void AddSensor(SCA_ISensor* act);
 	void AddController(SCA_IController* act);
@@ -97,20 +106,26 @@
 	SCA_IActuator* FindActuator(const STR_String& actuatorname);
 	SCA_IController* FindController(const STR_String& controllername);
 
-	void SetCurrentTime(float currentTime);
+	void SetCurrentTime(float currentTime) {}
 
 	void ReParentLogic();
 	
 	/**
 	 * Set whether or not to ignore activity culling requests
 	 */
-	void SetIgnoreActivityCulling(bool b);
+	void SetIgnoreActivityCulling(bool b)
+	{
+		m_ignore_activity_culling = b;
+	}
 
 	/**
 	 * Set whether or not this object wants to ignore activity culling
 	 * requests
 	 */
-	bool GetIgnoreActivityCulling();
+	bool GetIgnoreActivityCulling()
+	{
+		return m_ignore_activity_culling;
+	}
 
 	/**
 	 * Suspend all progress.

Modified: trunk/blender/source/gameengine/Ketsji/KX_GameObject.h
===================================================================
--- trunk/blender/source/gameengine/Ketsji/KX_GameObject.h	2009-05-03 21:42:39 UTC (rev 20046)
+++ trunk/blender/source/gameengine/Ketsji/KX_GameObject.h	2009-05-03 21:51:57 UTC (rev 20047)
@@ -192,11 +192,6 @@
 	~KX_GameObject(
 	);
 
-		CValue*				
-	AddRef() { 
-		/* temporarily to find memleaks */ return CValue::AddRef(); 
-	}
-
 	/** 
 	 * @section Stuff which is here due to poor design.
 	 * Inherited from CValue and needs an implementation. 





More information about the Bf-blender-cvs mailing list