CValue* CValue::ConvertPythonToValue(PyObject* pyobj, const char *error_prefix) { CValue* vallie = NULL; /* refcounting is broking here! - this crashes anyway, just store a python list for KX_GameObject */ #if 0 if (PyList_Check(pyobj)) { CListValue* listval = new CListValue(); bool error = false; Py_ssize_t i; Py_ssize_t numitems = PyList_GET_SIZE(pyobj); for (i=0;i<numitems;i++) { PyObject* listitem = PyList_GetItem(pyobj,i); /* borrowed ref */ CValue* listitemval = ConvertPythonToValue(listitem, error_prefix); if (listitemval) { listval->Add(listitemval); } else { error = true; } } if (!error) { // jippie! could be converted vallie = listval; } else { // list could not be converted... bad luck listval->Release(); } } else #endif if (PyFloat_Check(pyobj)) { vallie = new CFloatValue( (float)PyFloat_AsDouble(pyobj) ); } else if (PyLong_Check(pyobj)) { vallie = new CIntValue( (cInt)PyLong_AsLongLong(pyobj) ); } else if (PyUnicode_Check(pyobj)) { vallie = new CStringValue(_PyUnicode_AsString(pyobj),""); } else if (PyObject_TypeCheck(pyobj, &CValue::Type)) /* Note, dont let these get assigned to GameObject props, must check elsewhere */ { vallie = (static_cast<CValue *>(BGE_PROXY_REF(pyobj)))->AddRef(); } else { /* return an error value from the caller */ PyErr_Format(PyExc_TypeError, "%scould convert python value to a game engine property", error_prefix); } return vallie; }
static void update_anim_thread_func(TaskPool *pool, void *taskdata, int UNUSED(threadid)) { KX_GameObject *gameobj, *child; CListValue *children; bool needs_update; double curtime = *(double*)BLI_task_pool_userdata(pool); gameobj = (KX_GameObject*)taskdata; // Non-armature updates are fast enough, so just update them needs_update = gameobj->GetGameObjectType() != SCA_IObject::OBJ_ARMATURE; if (!needs_update) { // If we got here, we're looking to update an armature, so check its // children meshes to see if we need to bother with a more expensive // pose update children = gameobj->GetChildren(); bool has_mesh = false, has_non_mesh = false; // Check for meshes that haven't been culled for (int j=0; j<children->GetCount(); ++j) { child = (KX_GameObject*)children->GetValue(j); if (!child->GetCulled()) { needs_update = true; break; } if (child->GetMeshCount() == 0) has_non_mesh = true; else has_mesh = true; } // If we didn't find a non-culled mesh, check to see // if we even have any meshes, and update if this // armature has only non-mesh children. if (!needs_update && !has_mesh && has_non_mesh) needs_update = true; children->Release(); } if (needs_update) gameobj->UpdateActionManager(curtime); }