[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [15451] trunk/blender/source: GameObject rayCast and rayCastTo were not setting exception strings ( causes return without exception set error)
Campbell Barton
ideasman42 at gmail.com
Sun Jul 6 16:11:30 CEST 2008
Revision: 15451
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=15451
Author: campbellbarton
Date: 2008-07-06 16:11:30 +0200 (Sun, 06 Jul 2008)
Log Message:
-----------
GameObject rayCast and rayCastTo were not setting exception strings (causes return without exception set error)
Also made game state buttons only have a dot in states that have controllers in them.
Modified Paths:
--------------
trunk/blender/source/blender/src/buttons_logic.c
trunk/blender/source/gameengine/Ketsji/KX_GameObject.cpp
Modified: trunk/blender/source/blender/src/buttons_logic.c
===================================================================
--- trunk/blender/source/blender/src/buttons_logic.c 2008-07-06 13:52:17 UTC (rev 15450)
+++ trunk/blender/source/blender/src/buttons_logic.c 2008-07-06 14:11:30 UTC (rev 15451)
@@ -3126,6 +3126,8 @@
ob= OBACT;
for(a=0; a<count; a++) {
+ unsigned int controller_state_mask = 0; /* store a bitmask for states that are used */
+
ob= (Object *)idar[a];
uiClearButLock();
uiSetButLock(object_is_libdata(ob), ERROR_LIBDATA_MESSAGE);
@@ -3150,6 +3152,7 @@
act = cont->links[iact];
act->flag |= ACT_LINKED;
}
+ controller_state_mask |= cont->state_mask;
cont = cont->next;
}
@@ -3164,11 +3167,11 @@
for (offset=0; offset<15; offset+=5) {
uiBlockBeginAlign(block);
for (stbit=0; stbit<5; stbit++) {
- but = uiDefButBitI(block, BUT_TOGDUAL, 1<<(stbit+offset), stbit+offset, "", (short)(xco+35+12*stbit+13*offset), yco, 12, 12, (int *)&(ob->state), 0, 0, 0, 0, get_state_name(ob, (short)(stbit+offset)));
+ but = uiDefButBitI(block, controller_state_mask&(1<<(stbit+offset)) ? BUT_TOGDUAL:TOG, 1<<(stbit+offset), stbit+offset, "", (short)(xco+35+12*stbit+13*offset), yco, 12, 12, (int *)&(ob->state), 0, 0, 0, 0, get_state_name(ob, (short)(stbit+offset)));
uiButSetFunc(but, check_object_state, but, &(ob->state));
}
for (stbit=0; stbit<5; stbit++) {
- but = uiDefButBitI(block, BUT_TOGDUAL, 1<<(stbit+offset+15), stbit+offset+15, "", (short)(xco+35+12*stbit+13*offset), yco-12, 12, 12, (int *)&(ob->state), 0, 0, 0, 0, get_state_name(ob, (short)(stbit+offset+15)));
+ but = uiDefButBitI(block, controller_state_mask&(1<<(stbit+offset)) ? BUT_TOGDUAL:TOG, 1<<(stbit+offset+15), stbit+offset+15, "", (short)(xco+35+12*stbit+13*offset), yco-12, 12, 12, (int *)&(ob->state), 0, 0, 0, 0, get_state_name(ob, (short)(stbit+offset+15)));
uiButSetFunc(but, check_object_state, but, &(ob->state));
}
}
Modified: trunk/blender/source/gameengine/Ketsji/KX_GameObject.cpp
===================================================================
--- trunk/blender/source/gameengine/Ketsji/KX_GameObject.cpp 2008-07-06 13:52:17 UTC (rev 15450)
+++ trunk/blender/source/gameengine/Ketsji/KX_GameObject.cpp 2008-07-06 14:11:30 UTC (rev 15451)
@@ -1506,8 +1506,10 @@
{
KX_GameObject *other;
PyErr_Clear();
- if (!PyType_IsSubtype(pyarg->ob_type, &KX_GameObject::Type))
+ if (!PyType_IsSubtype(pyarg->ob_type, &KX_GameObject::Type)) {
+ PyErr_SetString(PyExc_TypeError, "the first argument to rayCastTo must be a vector or a KX_GameObject");
return NULL;
+ }
other = static_cast<KX_GameObject*>(pyarg);
toPoint = other->NodeGetWorldPosition();
}
@@ -1567,8 +1569,10 @@
if (!PyVecTo(pyto, toPoint))
{
PyErr_Clear();
- if (!PyType_IsSubtype(pyto->ob_type, &KX_GameObject::Type))
+ if (!PyType_IsSubtype(pyto->ob_type, &KX_GameObject::Type)) {
+ PyErr_SetString(PyExc_TypeError, "the first argument to rayCast must be a vector or a KX_GameObject");
return NULL;
+ }
other = static_cast<KX_GameObject*>(pyto);
toPoint = other->NodeGetWorldPosition();
}
@@ -1579,8 +1583,10 @@
else if (!PyVecTo(pyfrom, fromPoint))
{
PyErr_Clear();
- if (!PyType_IsSubtype(pyfrom->ob_type, &KX_GameObject::Type))
+ if (!PyType_IsSubtype(pyfrom->ob_type, &KX_GameObject::Type)) {
+ PyErr_SetString(PyExc_TypeError, "the second optional argument to rayCast must be a vector or a KX_GameObject");
return NULL;
+ }
other = static_cast<KX_GameObject*>(pyfrom);
fromPoint = other->NodeGetWorldPosition();
}
More information about the Bf-blender-cvs
mailing list