bool KX_StateActuator::Update() { bool bNegativeEvent = IsNegativeEvent(); unsigned int objMask; // execution of state actuator means that we are in the execution phase, reset this pointer // because all the active actuator of this object will be removed for sure. m_gameobj->m_firstState = NULL; RemoveAllEvents(); if (bNegativeEvent) return false; KX_GameObject *obj = (KX_GameObject*) GetParent(); objMask = obj->GetState(); switch (m_operation) { case OP_CPY: objMask = m_mask; break; case OP_SET: objMask |= m_mask; break; case OP_CLR: objMask &= ~m_mask; break; case OP_NEG: objMask ^= m_mask; break; default: // unsupported operation, no nothing return false; } obj->SetState(objMask); return false; }
void KX_KetsjiEngine::RenderDebugProperties() { STR_String debugtxt; int xcoord = 10; // mmmm, these constants were taken from blender source int ycoord = 14; // to 'mimic' behaviour float tottime = m_logger->GetAverage(); if (tottime < 1e-6f) { tottime = 1e-6f; } // Set viewport to entire canvas RAS_Rect viewport; m_canvas->SetViewPort(0, 0, int(m_canvas->GetWidth()), int(m_canvas->GetHeight())); /* Framerate display */ if (m_show_framerate) { debugtxt.Format("swap : %.3f (%.3f frames per second)", tottime, 1.0/tottime); m_rendertools->RenderText2D(RAS_IRenderTools::RAS_TEXT_PADDED, debugtxt.Ptr(), xcoord, ycoord, m_canvas->GetWidth() /* RdV, TODO ?? */, m_canvas->GetHeight() /* RdV, TODO ?? */); ycoord += 14; } /* Profile and framerate display */ if (m_show_profile) { for (int j = tc_first; j < tc_numCategories; j++) { debugtxt.Format(m_profileLabels[j]); m_rendertools->RenderText2D(RAS_IRenderTools::RAS_TEXT_PADDED, debugtxt.Ptr(), xcoord,ycoord, m_canvas->GetWidth(), m_canvas->GetHeight()); double time = m_logger->GetAverage((KX_TimeCategory)j); debugtxt.Format("%.3fms (%2.2f %%)", time*1000.f, time/tottime * 100.f); m_rendertools->RenderText2D(RAS_IRenderTools::RAS_TEXT_PADDED, debugtxt.Ptr(), xcoord + 60 ,ycoord, m_canvas->GetWidth(), m_canvas->GetHeight()); ycoord += 14; } } /* Property display*/ if (m_show_debug_properties && m_propertiesPresent) { KX_SceneList::iterator sceneit; for (sceneit = m_scenes.begin();sceneit != m_scenes.end() ; sceneit++) { KX_Scene* scene = *sceneit; /* the 'normal' debug props */ vector<SCA_DebugProp*>& debugproplist = scene->GetDebugProperties(); for (vector<SCA_DebugProp*>::iterator it = debugproplist.begin(); !(it==debugproplist.end());it++) { CValue* propobj = (*it)->m_obj; STR_String objname = propobj->GetName(); STR_String propname = (*it)->m_name; if (propname == "__state__") { // reserve name for object state KX_GameObject* gameobj = static_cast<KX_GameObject*>(propobj); unsigned int state = gameobj->GetState(); debugtxt = objname + "." + propname + " = "; bool first = true; for (int statenum=1;state;state >>= 1, statenum++) { if (state & 1) { if (!first) { debugtxt += ","; } debugtxt += STR_String(statenum); first = false; } } m_rendertools->RenderText2D(RAS_IRenderTools::RAS_TEXT_PADDED, debugtxt.Ptr(), xcoord, ycoord, m_canvas->GetWidth(), m_canvas->GetHeight()); ycoord += 14; } else { CValue* propval = propobj->GetProperty(propname); if (propval) { STR_String text = propval->GetText(); debugtxt = objname + "." + propname + " = " + text; m_rendertools->RenderText2D(RAS_IRenderTools::RAS_TEXT_PADDED, debugtxt.Ptr(), xcoord, ycoord, m_canvas->GetWidth(), m_canvas->GetHeight()); ycoord += 14; } } }