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
This commit is contained in:
@@ -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].
|
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.
|
Mist and background color sould always set to the same color.
|
||||||
|
|
||||||
:type: :class:`mathutils.Vector`
|
:type: :class:`mathutils.Color`
|
||||||
|
|
||||||
.. attribute:: backgroundColor
|
.. attribute:: backgroundColor
|
||||||
|
|
||||||
The color of the background. Black = [0.0, 0.0, 0.0], White = [1.0, 1.0, 1.0].
|
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.
|
Mist and background color sould always set to the same color.
|
||||||
|
|
||||||
:type: :class:`mathutils.Vector`
|
:type: :class:`mathutils.Color`
|
||||||
|
|
||||||
.. attribute:: ambientColor
|
.. attribute:: ambientColor
|
||||||
|
|
||||||
The color of the ambient light. Black = [0.0, 0.0, 0.0], White = [1.0, 1.0, 1.0].
|
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`
|
||||||
|
@@ -253,11 +253,11 @@ PyAttributeDef KX_WorldInfo::Attributes[] = {
|
|||||||
/*----------------------mathutils callbacks ----------------------------*/
|
/*----------------------mathutils callbacks ----------------------------*/
|
||||||
|
|
||||||
/* subtype */
|
/* subtype */
|
||||||
#define MATHUTILS_VEC_CB_MIST_COLOR 1
|
#define MATHUTILS_COL_CB_MIST_COLOR 1
|
||||||
#define MATHUTILS_VEC_CB_BACK_COLOR 2
|
#define MATHUTILS_COL_CB_BACK_COLOR 2
|
||||||
#define MATHUTILS_VEC_CB_AMBIENT_COLOR 3
|
#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)
|
static int mathutils_world_generic_check(BaseMathObject *bmo)
|
||||||
{
|
{
|
||||||
@@ -268,20 +268,20 @@ static int mathutils_world_generic_check(BaseMathObject *bmo)
|
|||||||
return 0;
|
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);
|
KX_WorldInfo *self = static_cast<KX_WorldInfo*>BGE_PROXY_REF(bmo->cb_user);
|
||||||
if (self == NULL)
|
if (self == NULL)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
switch (subtype) {
|
switch (subtype) {
|
||||||
case MATHUTILS_VEC_CB_MIST_COLOR:
|
case MATHUTILS_COL_CB_MIST_COLOR:
|
||||||
copy_v3_v3(bmo->data, self->m_mistcolor);
|
copy_v3_v3(bmo->data, self->m_mistcolor);
|
||||||
break;
|
break;
|
||||||
case MATHUTILS_VEC_CB_BACK_COLOR:
|
case MATHUTILS_COL_CB_BACK_COLOR:
|
||||||
copy_v3_v3(bmo->data, self->m_backgroundcolor);
|
copy_v3_v3(bmo->data, self->m_backgroundcolor);
|
||||||
break;
|
break;
|
||||||
case MATHUTILS_VEC_CB_AMBIENT_COLOR:
|
case MATHUTILS_COL_CB_AMBIENT_COLOR:
|
||||||
copy_v3_v3(bmo->data, self->m_ambientcolor);
|
copy_v3_v3(bmo->data, self->m_ambientcolor);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@@ -290,7 +290,7 @@ static int mathutils_world_vector_get(BaseMathObject *bmo, int subtype)
|
|||||||
return 0;
|
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);
|
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;
|
return -1;
|
||||||
|
|
||||||
switch (subtype) {
|
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]);
|
self->setMistColor(bmo->data[0], bmo->data[1], bmo->data[2]);
|
||||||
break;
|
break;
|
||||||
case MATHUTILS_VEC_CB_BACK_COLOR:
|
case MATHUTILS_COL_CB_BACK_COLOR:
|
||||||
self->setBackColor(bmo->data[0], bmo->data[1], bmo->data[2]);
|
self->setBackColor(bmo->data[0], bmo->data[1], bmo->data[2]);
|
||||||
break;
|
break;
|
||||||
case MATHUTILS_VEC_CB_AMBIENT_COLOR:
|
case MATHUTILS_COL_CB_AMBIENT_COLOR:
|
||||||
self->setAmbientColor(bmo->data[0], bmo->data[1], bmo->data[2]);
|
self->setAmbientColor(bmo->data[0], bmo->data[1], bmo->data[2]);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@@ -313,7 +313,7 @@ static int mathutils_world_vector_set(BaseMathObject *bmo, int subtype)
|
|||||||
return 0;
|
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);
|
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;
|
return -1;
|
||||||
|
|
||||||
switch (subtype) {
|
switch (subtype) {
|
||||||
case MATHUTILS_VEC_CB_MIST_COLOR:
|
case MATHUTILS_COL_CB_MIST_COLOR:
|
||||||
{
|
{
|
||||||
const float *color = self->m_mistcolor;
|
const float *color = self->m_mistcolor;
|
||||||
bmo->data[index] = color[index];
|
bmo->data[index] = color[index];
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case MATHUTILS_VEC_CB_BACK_COLOR:
|
case MATHUTILS_COL_CB_BACK_COLOR:
|
||||||
{
|
{
|
||||||
const float *color = self->m_backgroundcolor;
|
const float *color = self->m_backgroundcolor;
|
||||||
bmo->data[index] = color[index];
|
bmo->data[index] = color[index];
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case MATHUTILS_VEC_CB_AMBIENT_COLOR:
|
case MATHUTILS_COL_CB_AMBIENT_COLOR:
|
||||||
{
|
{
|
||||||
const float *color = self->m_ambientcolor;
|
const float *color = self->m_ambientcolor;
|
||||||
bmo->data[index] = color[index];
|
bmo->data[index] = color[index];
|
||||||
@@ -345,7 +345,7 @@ static int mathutils_world_vector_get_index(BaseMathObject *bmo, int subtype, in
|
|||||||
return 0;
|
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);
|
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];
|
float color[4];
|
||||||
switch (subtype) {
|
switch (subtype) {
|
||||||
case MATHUTILS_VEC_CB_MIST_COLOR:
|
case MATHUTILS_COL_CB_MIST_COLOR:
|
||||||
copy_v3_v3(color, self->m_mistcolor);
|
copy_v3_v3(color, self->m_mistcolor);
|
||||||
color[index] = bmo->data[index];
|
color[index] = bmo->data[index];
|
||||||
self->setMistColor(color[0], color[1], color[2]);
|
self->setMistColor(color[0], color[1], color[2]);
|
||||||
break;
|
break;
|
||||||
case MATHUTILS_VEC_CB_BACK_COLOR:
|
case MATHUTILS_COL_CB_BACK_COLOR:
|
||||||
copy_v3_v3(color, self->m_backgroundcolor);
|
copy_v3_v3(color, self->m_backgroundcolor);
|
||||||
color[index] = bmo->data[index];
|
color[index] = bmo->data[index];
|
||||||
self->setBackColor(color[0], color[1], color[2]);
|
self->setBackColor(color[0], color[1], color[2]);
|
||||||
break;
|
break;
|
||||||
case MATHUTILS_VEC_CB_AMBIENT_COLOR:
|
case MATHUTILS_COL_CB_AMBIENT_COLOR:
|
||||||
copy_v3_v3(color, self->m_ambientcolor);
|
copy_v3_v3(color, self->m_ambientcolor);
|
||||||
color[index] = bmo->data[index];
|
color[index] = bmo->data[index];
|
||||||
self->setAmbientColor(color[0], color[1], color[2]);
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Mathutils_Callback mathutils_world_vector_cb = {
|
static Mathutils_Callback mathutils_world_color_cb = {
|
||||||
mathutils_world_generic_check,
|
mathutils_world_generic_check,
|
||||||
mathutils_world_vector_get,
|
mathutils_world_color_get,
|
||||||
mathutils_world_vector_set,
|
mathutils_world_color_set,
|
||||||
mathutils_world_vector_get_index,
|
mathutils_world_color_get_index,
|
||||||
mathutils_world_vector_set_index
|
mathutils_world_color_set_index
|
||||||
};
|
};
|
||||||
|
|
||||||
void KX_WorldInfo_Mathutils_Callback_Init()
|
void KX_WorldInfo_Mathutils_Callback_Init()
|
||||||
{
|
{
|
||||||
// register mathutils callbacks, ok to run more than once.
|
// 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
|
#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)
|
PyObject *KX_WorldInfo::pyattr_get_mist_color(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
|
||||||
{
|
{
|
||||||
#ifdef USE_MATHUTILS
|
#ifdef USE_MATHUTILS
|
||||||
return Vector_CreatePyObject_cb(
|
return Color_CreatePyObject_cb(
|
||||||
BGE_PROXY_FROM_REF_BORROW(self_v), 3,
|
BGE_PROXY_FROM_REF_BORROW(self_v),
|
||||||
mathutils_world_vector_cb_index, MATHUTILS_VEC_CB_MIST_COLOR);
|
mathutils_world_color_cb_index, MATHUTILS_COL_CB_MIST_COLOR);
|
||||||
#else
|
#else
|
||||||
KX_WorldInfo *self = static_cast<KX_WorldInfo*>(self_v);
|
KX_WorldInfo *self = static_cast<KX_WorldInfo*>(self_v);
|
||||||
return PyObjectFrom(MT_Vector3(self->m_mistcolor));
|
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
|
#ifdef USE_MATHUTILS
|
||||||
return Vector_CreatePyObject_cb(
|
return Color_CreatePyObject_cb(
|
||||||
BGE_PROXY_FROM_REF_BORROW(self_v), 3,
|
BGE_PROXY_FROM_REF_BORROW(self_v),
|
||||||
mathutils_world_vector_cb_index, MATHUTILS_VEC_CB_BACK_COLOR);
|
mathutils_world_color_cb_index, MATHUTILS_COL_CB_BACK_COLOR);
|
||||||
#else
|
#else
|
||||||
KX_WorldInfo *self = static_cast<KX_WorldInfo*>(self_v);
|
KX_WorldInfo *self = static_cast<KX_WorldInfo*>(self_v);
|
||||||
return PyObjectFrom(MT_Vector3(self->m_backgroundcolor));
|
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)
|
PyObject *KX_WorldInfo::pyattr_get_ambient_color(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
|
||||||
{
|
{
|
||||||
#ifdef USE_MATHUTILS
|
#ifdef USE_MATHUTILS
|
||||||
return Vector_CreatePyObject_cb(
|
return Color_CreatePyObject_cb(
|
||||||
BGE_PROXY_FROM_REF_BORROW(self_v), 3,
|
BGE_PROXY_FROM_REF_BORROW(self_v),
|
||||||
mathutils_world_vector_cb_index, MATHUTILS_VEC_CB_AMBIENT_COLOR);
|
mathutils_world_color_cb_index, MATHUTILS_COL_CB_AMBIENT_COLOR);
|
||||||
#else
|
#else
|
||||||
KX_WorldInfo *self = static_cast<KX_WorldInfo*>(self_v);
|
KX_WorldInfo *self = static_cast<KX_WorldInfo*>(self_v);
|
||||||
return PyObjectFrom(MT_Vector3(self->m_ambientcolor));
|
return PyObjectFrom(MT_Vector3(self->m_ambientcolor));
|
||||||
|
Reference in New Issue
Block a user