[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [43154] trunk/blender/source: more edits to r43145,

Campbell Barton ideasman42 at gmail.com
Thu Jan 5 07:34:28 CET 2012


Revision: 43154
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=43154
Author:   campbellbarton
Date:     2012-01-05 06:34:14 +0000 (Thu, 05 Jan 2012)
Log Message:
-----------
more edits to r43145,
- remove redundant check in new prop operator which is covered by operators poll func.
- use get_ob_property to get the object prop in BL_ConvertTextProperty() rather then looping for it.

Revision Links:
--------------
    http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=43145

Modified Paths:
--------------
    trunk/blender/source/blender/editors/object/object_edit.c
    trunk/blender/source/gameengine/Converter/KX_ConvertProperties.cpp

Modified: trunk/blender/source/blender/editors/object/object_edit.c
===================================================================
--- trunk/blender/source/blender/editors/object/object_edit.c	2012-01-05 06:12:26 UTC (rev 43153)
+++ trunk/blender/source/blender/editors/object/object_edit.c	2012-01-05 06:34:14 UTC (rev 43154)
@@ -1943,15 +1943,13 @@
 	char name[32];
 	int type= RNA_enum_get(op->ptr, "type");
 
-	if(!ob)
-		return OPERATOR_CANCELLED;
-
 	prop= new_property(type);
 	BLI_addtail(&ob->prop, prop);
 
 	RNA_string_get(op->ptr, "name", name);
-	if(BLI_strnlen(name, 32) > 0)
+	if (name[0] != '\0') {
 		BLI_strncpy(prop->name, name, sizeof(prop->name));
+	}
 
 	unique_property(NULL, prop, 0); // make_unique_prop_names(prop->name);
 

Modified: trunk/blender/source/gameengine/Converter/KX_ConvertProperties.cpp
===================================================================
--- trunk/blender/source/gameengine/Converter/KX_ConvertProperties.cpp	2012-01-05 06:12:26 UTC (rev 43153)
+++ trunk/blender/source/gameengine/Converter/KX_ConvertProperties.cpp	2012-01-05 06:34:14 UTC (rev 43154)
@@ -56,6 +56,9 @@
 #include "BLI_winstuff.h"
 #endif
 
+extern "C" {
+	#include "BKE_property.h"
+}
 
 /* prototype */
 void BL_ConvertTextProperty(Object* object, KX_FontObject* fontobj,SCA_TimeEventManager* timemgr,SCA_IScene* scene, bool isInActiveLayer);
@@ -174,79 +177,68 @@
 {
 	CValue* tprop = fontobj->GetProperty("Text");
 	if(!tprop) return;
+	bProperty* prop = get_ob_property(object, "Text");
+	if(!prop) return;
 
 	Curve *curve = static_cast<Curve *>(object->data);
 	STR_String str = curve->str;
+	CValue* propval = NULL;
 
-	bProperty* prop = (bProperty*)object->prop.first;
-	CValue* propval;	
-
-	while(prop)
-	{
-		if (strcmp(prop->name, "Text")!=0) {
-			prop = prop->next;
-			continue;
+	switch(prop->type) {
+		case GPROP_BOOL:
+		{
+			int value = atoi(str);
+			propval = new CBoolValue((bool)(value != 0));
+			tprop->SetValue(propval);
+			break;
 		}
-	
-		propval = NULL;
+		case GPROP_INT:
+		{
+			int value = atoi(str);
+			propval = new CIntValue(value);
+			tprop->SetValue(propval);
+			break;
+		}
+		case GPROP_FLOAT:
+		{
+			float floatprop = atof(str);
+			propval = new CFloatValue(floatprop);
+			tprop->SetValue(propval);
+			break;
+		}
+		case GPROP_STRING:
+		{
+			propval = new CStringValue(str, "");
+			tprop->SetValue(propval);
+			break;
+		}
+		case GPROP_TIME:
+		{
+			float floatprop = atof(str);
 
-		switch(prop->type) {
-			case GPROP_BOOL:
+			CValue* timeval = new CFloatValue(floatprop);
+			// set a subproperty called 'timer' so that
+			// we can register the replica of this property
+			// at the time a game object is replicated (AddObjectActuator triggers this)
+			CValue *bval = new CBoolValue(true);
+			timeval->SetProperty("timer",bval);
+			bval->Release();
+			if (isInActiveLayer)
 			{
-				int value = atoi(str);
-				propval = new CBoolValue((bool)(value != 0));
-				tprop->SetValue(propval);
-				break;
+				timemgr->AddTimeProperty(timeval);
 			}
-			case GPROP_INT:
-			{
-				int value = atoi(str);
-				propval = new CIntValue(value);
-				tprop->SetValue(propval);
-				break;
-			}
-			case GPROP_FLOAT:
-			{
-				float floatprop = atof(str);
-				propval = new CFloatValue(floatprop);
-				tprop->SetValue(propval);
-				break;
-			}
-			case GPROP_STRING:
-			{
-				propval = new CStringValue(str, "");
-				tprop->SetValue(propval);
-				break;
-			}
-			case GPROP_TIME:
-			{
-				float floatprop = atof(str);
 
-				CValue* timeval = new CFloatValue(floatprop);
-				// set a subproperty called 'timer' so that 
-				// we can register the replica of this property 
-				// at the time a game object is replicated (AddObjectActuator triggers this)
-				CValue *bval = new CBoolValue(true);
-				timeval->SetProperty("timer",bval);
-				bval->Release();
-				if (isInActiveLayer)
-				{
-					timemgr->AddTimeProperty(timeval);
-				}
-				
-				propval = timeval;
-				tprop->SetValue(timeval);
-			}
-			default:
-			{
-				// todo make an assert etc.
-			}
+			propval = timeval;
+			tprop->SetValue(timeval);
 		}
-		
-		if (propval)
-			propval->Release();
+		default:
+		{
+			// todo make an assert etc.
+		}
+	}
 
-		prop = prop->next;
+	if (propval) {
+		propval->Release();
 	}
 }
 



More information about the Bf-blender-cvs mailing list