void PhysicsServerSW::body_set_force_integration_callback(RID p_body,Object *p_receiver,const StringName& p_method,const Variant& p_udata) { BodySW *body = body_owner.get(p_body); ERR_FAIL_COND(!body); body->set_force_integration_callback(p_receiver?p_receiver->get_instance_ID():ObjectID(0),p_method,p_udata); }
ObjectID BulletPhysicsServer::area_get_object_instance_id(RID p_area) const { if (space_owner.owns(p_area)) { return 0; } AreaBullet *area = area_owner.get(p_area); ERR_FAIL_COND_V(!area, ObjectID()); return area->get_instance_id(); }
void CmpInventory::remove_item(const ObjectID& id) { initialise_if_necessary(); m_items.erase(id); m_objectManager->remove_listener(this, id); if(m_activeItem == id) m_activeItem = ObjectID(); ICmpUsable_Ptr cmpItemUsable = m_objectManager->get_component(id, cmpItemUsable); if(cmpItemUsable) m_groups[cmpItemUsable->usable_group()].erase(id); }
MessageResult ComponentManager::sendMessage(const InterfaceTypeID& iid, const ObjectID& oid, MessageBase& msg) { const ComponentID& cid = getComponentID(iid, oid); if (cid.isValid()) { ComponentBase* component = getComponent(cid); if (component) { // write on envelope // this changes msg! msg.Addressee = oid; msg.Sender = ObjectID(); return component->handleMessage(msg); } std::cerr << "Component invalid in container " << oid.getIndex() << std::endl; return MR_ERROR; // failed to deliver } return MR_ERROR; // failed to deliver }
void ControllerUI::Amount::Drop() { // get user entered amount const CEGUI::String& strVal = Value->getText(); // check if (strVal != STRINGEMPTY && ObjectID::IsValid(ID)) { // convert to uint unsigned int intVal = CEGUI::PropertyHelper<unsigned int>::fromString(strVal); // drop it OgreClient::Singleton->SendReqDropMessage(gcnew ObjectID(ID, intVal)); // hide window ControllerUI::Amount::Window->hide(); // mark GUIroot active ControllerUI::ActivateRoot(); } };
//#################### SAVING METHODS #################### void ObjectsSection::save(std::ostream& os, const ObjectManager_Ptr& objectManager) { objectManager->consolidate_object_ids(); os << "Objects\n"; os << "{\n"; os << '\t'; int objectCount = objectManager->object_count(); FieldIO::write_typed_field(os, "Count", objectCount); // Note: The objects with the specified IDs are guaranteed to exist because we called consolidate_object_ids() above. // This would not necessarily be the case otherwise, as the IDs of the objects may not form a contiguous series. for(int i=0; i<objectCount; ++i) { std::vector<IObjectComponent_Ptr> components = objectManager->get_components(ObjectID(i)); save_object(os, components, objectManager->component_property_types()); } os << "}\n"; }
void ScriptEditorDebugger::_parse_message(const String& p_msg,const Array& p_data) { if (p_msg=="debug_enter") { Array msg; msg.push_back("get_stack_dump"); ppeer->put_var(msg); ERR_FAIL_COND(p_data.size()!=2); bool can_continue=p_data[0]; String error = p_data[1]; step->set_disabled(!can_continue); next->set_disabled(!can_continue); reason->set_text(error); reason->set_tooltip(error); breaked=true; dobreak->set_disabled(true); docontinue->set_disabled(false); emit_signal("breaked",true,can_continue); OS::get_singleton()->move_window_to_foreground(); if (error!="") { tabs->set_current_tab(0); } profiler->set_enabled(false); EditorNode::get_singleton()->get_pause_button()->set_pressed(true); EditorNode::get_singleton()->make_bottom_panel_item_visible(this); } else if (p_msg=="debug_exit") { breaked=false; step->set_disabled(true); next->set_disabled(true); reason->set_text(""); reason->set_tooltip(""); back->set_disabled(true); forward->set_disabled(true); dobreak->set_disabled(false); docontinue->set_disabled(true); emit_signal("breaked",false,false,Variant()); //tabs->set_current_tab(0); profiler->set_enabled(true); profiler->disable_seeking(); EditorNode::get_singleton()->get_pause_button()->set_pressed(false); } else if (p_msg=="message:click_ctrl") { clicked_ctrl->set_text(p_data[0]); clicked_ctrl_type->set_text(p_data[1]); } else if (p_msg=="message:scene_tree") { inspect_scene_tree->clear(); Map<int,TreeItem*> lv; updating_scene_tree=true; for(int i=0;i<p_data.size();i+=4) { TreeItem *p; int level = p_data[i]; if (level==0) { p = NULL; } else { ERR_CONTINUE(!lv.has(level-1)); p=lv[level-1]; } TreeItem *it = inspect_scene_tree->create_item(p); ObjectID id = ObjectID(p_data[i+3]); it->set_text(0,p_data[i+1]); if (has_icon(p_data[i+2],"EditorIcons")) it->set_icon(0,get_icon(p_data[i+2],"EditorIcons")); it->set_metadata(0,id); if (id==inspected_object_id) { it->select(0); } if (p) { if (!unfold_cache.has(id)) { it->set_collapsed(true); } } else { if (unfold_cache.has(id)) { //reverse for root it->set_collapsed(true); } } lv[level]=it; } updating_scene_tree=false; le_clear->set_disabled(false); le_set->set_disabled(false); } else if (p_msg=="message:inspect_object") { ObjectID id = p_data[0]; String type = p_data[1]; Variant path = p_data[2]; //what to do yet, i don't know int prop_count=p_data[3]; int idx=4; if (inspected_object->last_edited_id!=id) { inspected_object->prop_list.clear(); inspected_object->prop_values.clear(); } for(int i=0;i<prop_count;i++) { PropertyInfo pinfo; pinfo.name=p_data[idx++]; pinfo.type=Variant::Type(int(p_data[idx++])); pinfo.hint=PropertyHint(int(p_data[idx++])); pinfo.hint_string=p_data[idx++]; if (pinfo.name.begins_with("*")) { pinfo.name=pinfo.name.substr(1,pinfo.name.length()); pinfo.usage=PROPERTY_USAGE_CATEGORY; } else { pinfo.usage=PROPERTY_USAGE_EDITOR; } if (inspected_object->last_edited_id!=id) { //don't update.. it's the same, instead refresh inspected_object->prop_list.push_back(pinfo); } inspected_object->prop_values[pinfo.name]=p_data[idx++]; if (inspected_object->last_edited_id==id) { //same, just update value, don't rebuild inspected_object->update_single(pinfo.name.ascii().get_data()); } } if (inspected_object->last_edited_id!=id) { //only if different inspected_object->update(); } inspected_object->last_edited_id=id; inspect_properties->edit(inspected_object); } else if (p_msg=="message:video_mem") { vmem_tree->clear(); TreeItem* root=vmem_tree->create_item(); int total=0; for(int i=0;i<p_data.size();i+=4) { TreeItem *it = vmem_tree->create_item(root); String type=p_data[i+1]; int bytes=p_data[i+3].operator int(); it->set_text(0,p_data[i+0]); //path it->set_text(1,type); //type it->set_text(2,p_data[i+2]); //type it->set_text(3,String::humanize_size(bytes)); //type total+=bytes; if (has_icon(type,"EditorIcons")) it->set_icon(0,get_icon(type,"EditorIcons")); } vmem_total->set_tooltip(TTR("Bytes:")+" "+itos(total)); vmem_total->set_text(String::humanize_size(total)); } else if (p_msg=="stack_dump") { stack_dump->clear(); TreeItem *r = stack_dump->create_item(); for(int i=0;i<p_data.size();i++) { Dictionary d = p_data[i]; ERR_CONTINUE(!d.has("function")); ERR_CONTINUE(!d.has("file")); ERR_CONTINUE(!d.has("line")); ERR_CONTINUE(!d.has("id")); TreeItem *s = stack_dump->create_item(r); d["frame"]=i; s->set_metadata(0,d); // String line = itos(i)+" - "+String(d["file"])+":"+itos(d["line"])+" - at func: "+d["function"]; String line = itos(i)+" - "+String(d["file"])+":"+itos(d["line"]); s->set_text(0,line); if (i==0) s->select(0); } } else if (p_msg=="stack_frame_vars") { variables->clear(); int ofs =0; int mcount = p_data[ofs]; ofs++; for(int i=0;i<mcount;i++) { String n = p_data[ofs+i*2+0]; Variant v = p_data[ofs+i*2+1]; if (n.begins_with("*")) { n=n.substr(1,n.length()); } variables->add_property("members/"+n,v); } ofs+=mcount*2; mcount = p_data[ofs]; ofs++; for(int i=0;i<mcount;i++) { String n = p_data[ofs+i*2+0]; Variant v = p_data[ofs+i*2+1]; if (n.begins_with("*")) { n=n.substr(1,n.length()); } variables->add_property("locals/"+n,v); } variables->update(); inspector->edit(variables); } else if (p_msg=="output") { //OUT for(int i=0;i<p_data.size();i++) { String t = p_data[i]; //LOG if (EditorNode::get_log()->is_hidden()) { log_forced_visible=true; if (EditorNode::get_singleton()->are_bottom_panels_hidden()) { EditorNode::get_singleton()->make_bottom_panel_item_visible(EditorNode::get_log()); } } EditorNode::get_log()->add_message(t); } } else if (p_msg=="performance") { Array arr = p_data[0]; Vector<float> p; p.resize(arr.size()); for(int i=0;i<arr.size();i++) { p[i]=arr[i]; if (i<perf_items.size()) { perf_items[i]->set_text(1,rtos(p[i])); if (p[i]>perf_max[i]) perf_max[i]=p[i]; } } perf_history.push_front(p); perf_draw->update(); } else if (p_msg=="error") { Array err = p_data[0]; Array vals; vals.push_back(err[0]); vals.push_back(err[1]); vals.push_back(err[2]); vals.push_back(err[3]); bool warning = err[9]; bool e; String time = String("%d:%02d:%02d:%04d").sprintf(vals,&e); String txt=time+" - "+(err[8].is_zero()?String(err[7]):String(err[8])); String tooltip=TTR("Type:")+String(warning?TTR("Warning"):TTR("Error")); tooltip+="\n"+TTR("Description:")+" "+String(err[8]); tooltip+="\n"+TTR("Time:")+" "+time; tooltip+="\nC "+TTR("Error:")+" "+String(err[7]); tooltip+="\nC "+TTR("Source:")+" "+String(err[5])+":"+String(err[6]); tooltip+="\nC "+TTR("Function:")+" "+String(err[4]); error_list->add_item(txt,EditorNode::get_singleton()->get_gui_base()->get_icon(warning?"Warning":"Error","EditorIcons")); error_list->set_item_tooltip( error_list->get_item_count() -1,tooltip ); int scc = p_data[1]; Array stack; stack.resize(scc); for(int i=0;i<scc;i++) { stack[i]=p_data[2+i]; } error_list->set_item_metadata( error_list->get_item_count() -1,stack ); error_count++; /* int count = p_data[1]; Array cstack; OutputError oe = errors.front()->get(); packet_peer_stream->put_var(oe.hr); packet_peer_stream->put_var(oe.min); packet_peer_stream->put_var(oe.sec); packet_peer_stream->put_var(oe.msec); packet_peer_stream->put_var(oe.source_func); packet_peer_stream->put_var(oe.source_file); packet_peer_stream->put_var(oe.source_line); packet_peer_stream->put_var(oe.error); packet_peer_stream->put_var(oe.error_descr); packet_peer_stream->put_var(oe.warning); packet_peer_stream->put_var(oe.callstack); */ } else if (p_msg=="profile_sig") { //cache a signature print_line("SIG: "+String(Variant(p_data))); profiler_signature[p_data[1]]=p_data[0]; } else if (p_msg=="profile_frame" || p_msg=="profile_total") { EditorProfiler::Metric metric; metric.valid=true; metric.frame_number=p_data[0]; metric.frame_time=p_data[1]; metric.idle_time=p_data[2]; metric.fixed_time=p_data[3]; metric.fixed_frame_time=p_data[4]; int frame_data_amount = p_data[6]; int frame_function_amount = p_data[7]; if (frame_data_amount) { EditorProfiler::Metric::Category frame_time; frame_time.signature="category_frame_time"; frame_time.name="Frame Time"; frame_time.total_time=metric.frame_time; EditorProfiler::Metric::Category::Item item; item.calls=1; item.line=0; item.name="Fixed Time"; item.total=metric.fixed_time; item.self=item.total; item.signature="fixed_time"; frame_time.items.push_back(item); item.name="Idle Time"; item.total=metric.idle_time; item.self=item.total; item.signature="idle_time"; frame_time.items.push_back(item); item.name="Fixed Frame Time"; item.total=metric.fixed_frame_time; item.self=item.total; item.signature="fixed_frame_time"; frame_time.items.push_back(item); metric.categories.push_back(frame_time); } int idx=8; for(int i=0;i<frame_data_amount;i++) { EditorProfiler::Metric::Category c; String name=p_data[idx++]; Array values=p_data[idx++]; c.name=name.capitalize(); c.items.resize(values.size()/2); c.total_time=0; c.signature="categ::"+name; for(int i=0;i<values.size();i+=2) { EditorProfiler::Metric::Category::Item item; item.name=values[i]; item.calls=1; item.self=values[i+1]; item.total=item.self; item.signature="categ::"+name+"::"+item.name; item.name=item.name.capitalize(); c.total_time+=item.total; c.items[i/2]=item; } metric.categories.push_back(c); } EditorProfiler::Metric::Category funcs; funcs.total_time=p_data[5]; //script time funcs.items.resize(frame_function_amount); funcs.name="Script Functions"; funcs.signature="script_functions"; for(int i=0;i<frame_function_amount;i++) { int signature = p_data[idx++]; int calls = p_data[idx++]; float total = p_data[idx++]; float self = p_data[idx++]; EditorProfiler::Metric::Category::Item item; if (profiler_signature.has(signature)) { item.signature=profiler_signature[signature]; String name = profiler_signature[signature]; Vector<String> strings = name.split("::"); if (strings.size()==3) { item.name=strings[2]; item.script=strings[0]; item.line=strings[1].to_int(); } } else { item.name="SigErr "+itos(signature); } item.calls=calls; item.self=self; item.total=total; funcs.items[i]=item; } metric.categories.push_back(funcs); if (p_msg=="profile_frame") profiler->add_frame_metric(metric,false); else profiler->add_frame_metric(metric,true); } else if (p_msg=="kill_me") { editor->call_deferred("stop_child_process"); } }
//#################### SPECIALIZATIONS #################### ObjectID PropReader<ObjectID>::read(std::string& input) { return ObjectID(PropReader<int>::read(input)); }
ObjectID ObjectManager::player() const { // FIXME: The object ID of the player should be loaded in, not hard-coded like this. return ObjectID(0); }
const Event * DefaultSchedulingManager::peekNextEvent(){ TimeWarpEventSet *eventSet = mySimulationManager->getEventSetManager(); ASSERT( eventSet != 0 ); const Event *earliestEvent = 0; int simMgrId = mySimulationManager->getSimulationManagerID(); for(int i = 0; i < mySimulationManager->getNumberOfSimulationObjects(); i++){ const Event *tempEvent = eventSet->peekEvent( mySimulationManager->getObjectHandle( ObjectID(i,simMgrId) ) ); if( earliestEvent != 0 && tempEvent != 0 ){ if( tempEvent->getReceiveTime() < earliestEvent->getReceiveTime() ){ earliestEvent = tempEvent; } else if(tempEvent->getReceiveTime() == earliestEvent->getReceiveTime()){ if(tempEvent->getEventId() < earliestEvent->getEventId()){ earliestEvent = tempEvent; } } } else if( earliestEvent == 0 && tempEvent != 0 ){ earliestEvent = tempEvent; } } if( earliestEvent != 0 ){ setLastScheduledEventTime( earliestEvent->getReceiveTime() ); } else{ setLastScheduledEventTime( mySimulationManager->getPositiveInfinity() ); } return earliestEvent; }