[Bf-blender-cvs] [bd6febc] master: BGE: Change KX_WolrdInfo mathutils vector to color

Thomas Szepe noreply at git.blender.org
Sun Oct 11 18:43:24 CEST 2015


Commit: bd6febc4c4fa6ef33e581b5e50b01ba8327b702c
Author: Thomas Szepe
Date:   Sun Oct 11 18:43:05 2015 +0200
Branches: master
https://developer.blender.org/rBbd6febc4c4fa6ef33e581b5e50b01ba8327b702c

BGE: Change KX_WolrdInfo mathutils vector to color

Change the mathutils callback from vector to color for mistColor, backgroundColor and ambientColor.

Reviewers: lordloki, campbellbarton, panzergame, moguri, sybren

Reviewed By: panzergame, moguri, sybren

Projects: #game_engine, #game_logic

Differential Revision: https://developer.blender.org/D1432

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

M	doc/python_api/rst/bge_types/bge.types.KX_WorldInfo.rst
M	source/gameengine/Ketsji/KX_WorldInfo.cpp

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

diff --git a/doc/python_api/rst/bge_types/bge.types.KX_WorldInfo.rst b/doc/python_api/rst/bge_types/bge.types.KX_WorldInfo.rst
index a636af4..1501d85 100644
--- a/doc/python_api/rst/bge_types/bge.types.KX_WorldInfo.rst
+++ b/doc/python_api/rst/bge_types/bge.types.KX_WorldInfo.rst
@@ -63,17 +63,17 @@ base class --- :class:`PyObjectPlus`
       The color of the mist. Black = [0.0, 0.0, 0.0], White = [1.0, 1.0, 1.0].
       Mist and background color sould always set to the same color.
 
-      :type: :class:`mathutils.Vector`
+      :type: :class:`mathutils.Color`
 
    .. attribute:: backgroundColor
 
       The color of the background. Black = [0.0, 0.0, 0.0], White = [1.0, 1.0, 1.0].
       Mist and background color sould always set to the same color.
 
-      :type: :class:`mathutils.Vector`
+      :type: :class:`mathutils.Color`
 
    .. attribute:: ambientColor
 
       The color of the ambient light. Black = [0.0, 0.0, 0.0], White = [1.0, 1.0, 1.0].
 
-      :type: :class:`mathutils.Vector`
+      :type: :class:`mathutils.Color`
diff --git a/source/gameengine/Ketsji/KX_WorldInfo.cpp b/source/gameengine/Ketsji/KX_WorldInfo.cpp
index 111d81c..be8b1ce 100644
--- a/source/gameengine/Ketsji/KX_WorldInfo.cpp
+++ b/source/gameengine/Ketsji/KX_WorldInfo.cpp
@@ -253,11 +253,11 @@ PyAttributeDef KX_WorldInfo::Attributes[] = {
 /*----------------------mathutils callbacks ----------------------------*/
 
 /* subtype */
-#define MATHUTILS_VEC_CB_MIST_COLOR 1
-#define MATHUTILS_VEC_CB_BACK_COLOR 2
-#define MATHUTILS_VEC_CB_AMBIENT_COLOR 3
+#define MATHUTILS_COL_CB_MIST_COLOR 1
+#define MATHUTILS_COL_CB_BACK_COLOR 2
+#define MATHUTILS_COL_CB_AMBIENT_COLOR 3
 
-static unsigned char mathutils_world_vector_cb_index = -1; /* index for our callbacks */
+static unsigned char mathutils_world_color_cb_index = -1; /* index for our callbacks */
 
 static int mathutils_world_generic_check(BaseMathObject *bmo)
 {
@@ -268,20 +268,20 @@ static int mathutils_world_generic_check(BaseMathObject *bmo)
 	return 0;
 }
 
-static int mathutils_world_vector_get(BaseMathObject *bmo, int subtype)
+static int mathutils_world_color_get(BaseMathObject *bmo, int subtype)
 {
 	KX_WorldInfo *self = static_cast<KX_WorldInfo*>BGE_PROXY_REF(bmo->cb_user);
 	if (self == NULL)
 		return -1;
 
 	switch (subtype) {
-		case MATHUTILS_VEC_CB_MIST_COLOR:
+		case MATHUTILS_COL_CB_MIST_COLOR:
 			copy_v3_v3(bmo->data, self->m_mistcolor);
 			break;
-		case MATHUTILS_VEC_CB_BACK_COLOR:
+		case MATHUTILS_COL_CB_BACK_COLOR:
 			copy_v3_v3(bmo->data, self->m_backgroundcolor);
 			break;
-		case MATHUTILS_VEC_CB_AMBIENT_COLOR:
+		case MATHUTILS_COL_CB_AMBIENT_COLOR:
 			copy_v3_v3(bmo->data, self->m_ambientcolor);
 			break;
 	default:
@@ -290,7 +290,7 @@ static int mathutils_world_vector_get(BaseMathObject *bmo, int subtype)
 	return 0;
 }
 
-static int mathutils_world_vector_set(BaseMathObject *bmo, int subtype)
+static int mathutils_world_color_set(BaseMathObject *bmo, int subtype)
 {
 	KX_WorldInfo *self = static_cast<KX_WorldInfo*>BGE_PROXY_REF(bmo->cb_user);
 
@@ -298,13 +298,13 @@ static int mathutils_world_vector_set(BaseMathObject *bmo, int subtype)
 		return -1;
 
 	switch (subtype) {
-		case MATHUTILS_VEC_CB_MIST_COLOR:
+		case MATHUTILS_COL_CB_MIST_COLOR:
 			self->setMistColor(bmo->data[0], bmo->data[1], bmo->data[2]);
 			break;
-		case MATHUTILS_VEC_CB_BACK_COLOR:
+		case MATHUTILS_COL_CB_BACK_COLOR:
 			self->setBackColor(bmo->data[0], bmo->data[1], bmo->data[2]);
 			break;
-		case MATHUTILS_VEC_CB_AMBIENT_COLOR:
+		case MATHUTILS_COL_CB_AMBIENT_COLOR:
 			self->setAmbientColor(bmo->data[0], bmo->data[1], bmo->data[2]);
 			break;
 	default:
@@ -313,7 +313,7 @@ static int mathutils_world_vector_set(BaseMathObject *bmo, int subtype)
 	return 0;
 }
 
-static int mathutils_world_vector_get_index(BaseMathObject *bmo, int subtype, int index)
+static int mathutils_world_color_get_index(BaseMathObject *bmo, int subtype, int index)
 {
 	KX_WorldInfo *self = static_cast<KX_WorldInfo*>BGE_PROXY_REF(bmo->cb_user);
 
@@ -321,19 +321,19 @@ static int mathutils_world_vector_get_index(BaseMathObject *bmo, int subtype, in
 		return -1;
 
 	switch (subtype) {
-		case MATHUTILS_VEC_CB_MIST_COLOR:
+		case MATHUTILS_COL_CB_MIST_COLOR:
 		{
 			const float *color = self->m_mistcolor;
 			bmo->data[index] = color[index];
 		}
 		break;
-		case MATHUTILS_VEC_CB_BACK_COLOR:
+		case MATHUTILS_COL_CB_BACK_COLOR:
 		{
 			const float *color = self->m_backgroundcolor;
 			bmo->data[index] = color[index];
 		}
 			break;
-		case MATHUTILS_VEC_CB_AMBIENT_COLOR:
+		case MATHUTILS_COL_CB_AMBIENT_COLOR:
 		{
 			const float *color = self->m_ambientcolor;
 			bmo->data[index] = color[index];
@@ -345,7 +345,7 @@ static int mathutils_world_vector_get_index(BaseMathObject *bmo, int subtype, in
 	return 0;
 }
 
-static int mathutils_world_vector_set_index(BaseMathObject *bmo, int subtype, int index)
+static int mathutils_world_color_set_index(BaseMathObject *bmo, int subtype, int index)
 {
 	KX_WorldInfo *self = static_cast<KX_WorldInfo*>BGE_PROXY_REF(bmo->cb_user);
 
@@ -354,17 +354,17 @@ static int mathutils_world_vector_set_index(BaseMathObject *bmo, int subtype, in
 
 	float color[4];
 	switch (subtype) {
-		case MATHUTILS_VEC_CB_MIST_COLOR:
+		case MATHUTILS_COL_CB_MIST_COLOR:
 			copy_v3_v3(color, self->m_mistcolor);
 			color[index] = bmo->data[index];
 			self->setMistColor(color[0], color[1], color[2]);
 		break;
-		case MATHUTILS_VEC_CB_BACK_COLOR:
+		case MATHUTILS_COL_CB_BACK_COLOR:
 			copy_v3_v3(color, self->m_backgroundcolor);
 			color[index] = bmo->data[index];
 			self->setBackColor(color[0], color[1], color[2]);
 		break;
-		case MATHUTILS_VEC_CB_AMBIENT_COLOR:
+		case MATHUTILS_COL_CB_AMBIENT_COLOR:
 			copy_v3_v3(color, self->m_ambientcolor);
 			color[index] = bmo->data[index];
 			self->setAmbientColor(color[0], color[1], color[2]);
@@ -375,18 +375,18 @@ static int mathutils_world_vector_set_index(BaseMathObject *bmo, int subtype, in
 	return 0;
 }
 
-static Mathutils_Callback mathutils_world_vector_cb = {
+static Mathutils_Callback mathutils_world_color_cb = {
 	mathutils_world_generic_check,
-	mathutils_world_vector_get,
-	mathutils_world_vector_set,
-	mathutils_world_vector_get_index,
-	mathutils_world_vector_set_index
+	mathutils_world_color_get,
+	mathutils_world_color_set,
+	mathutils_world_color_get_index,
+	mathutils_world_color_set_index
 };
 
 void KX_WorldInfo_Mathutils_Callback_Init()
 {
 	// register mathutils callbacks, ok to run more than once.
-	mathutils_world_vector_cb_index = Mathutils_RegisterCallback(&mathutils_world_vector_cb);
+	mathutils_world_color_cb_index = Mathutils_RegisterCallback(&mathutils_world_color_cb);
 }
 #endif // USE_MATHUTILS
 
@@ -418,9 +418,9 @@ PyObject *KX_WorldInfo::pyattr_get_mist_typeconst(void *self_v, const KX_PYATTRI
 PyObject *KX_WorldInfo::pyattr_get_mist_color(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
 {
 #ifdef USE_MATHUTILS
-	return Vector_CreatePyObject_cb(
-	        BGE_PROXY_FROM_REF_BORROW(self_v), 3,
-	        mathutils_world_vector_cb_index, MATHUTILS_VEC_CB_MIST_COLOR);
+	return Color_CreatePyObject_cb(
+	        BGE_PROXY_FROM_REF_BORROW(self_v),
+	        mathutils_world_color_cb_index, MATHUTILS_COL_CB_MIST_COLOR);
 #else
 	KX_WorldInfo *self = static_cast<KX_WorldInfo*>(self_v);
 	return PyObjectFrom(MT_Vector3(self->m_mistcolor));
@@ -444,9 +444,9 @@ PyObject *KX_WorldInfo::pyattr_get_back_color(void *self_v, const KX_PYATTRIBUTE
 {
 
 #ifdef USE_MATHUTILS
-	return Vector_CreatePyObject_cb(
-	        BGE_PROXY_FROM_REF_BORROW(self_v), 3,
-	        mathutils_world_vector_cb_index, MATHUTILS_VEC_CB_BACK_COLOR);
+	return Color_CreatePyObject_cb(
+	        BGE_PROXY_FROM_REF_BORROW(self_v),
+	        mathutils_world_color_cb_index, MATHUTILS_COL_CB_BACK_COLOR);
 #else
 	KX_WorldInfo *self = static_cast<KX_WorldInfo*>(self_v);
 	return PyObjectFrom(MT_Vector3(self->m_backgroundcolor));
@@ -469,9 +469,9 @@ int KX_WorldInfo::pyattr_set_back_color(void *self_v, const KX_PYATTRIBUTE_DEF *
 PyObject *KX_WorldInfo::pyattr_get_ambient_color(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
 {
 #ifdef USE_MATHUTILS
-	return Vector_CreatePyObject_cb(
-	        BGE_PROXY_FROM_REF_BORROW(self_v), 3,
-	        mathutils_world_vector_cb_index, MATHUTILS_VEC_CB_AMBIENT_COLOR);
+	return Color_CreatePyObject_cb(
+	        BGE_PROXY_FROM_REF_BORROW(self_v),
+	        mathutils_world_color_cb_index, MATHUTILS_COL_CB_AMBIENT_COLOR);
 #else
 	KX_WorldInfo *self = static_cast<KX_WorldInfo*>(self_v);
 	return PyObjectFrom(MT_Vector3(self->m_ambientcolor));




More information about the Bf-blender-cvs mailing list