oni_adapter_plugin::~oni_adapter_plugin() { PROFILE_FUNC(); #ifndef __ANDROID__ PROFILE_UPDATE(); PROFILE_OUTPUT("profile_openni_sensor.txt"); #endif streamsets_.clear(); LOG_INFO("orbbec.ni.oni_adapter_plugin", "shutting down openni"); openni::OpenNI::shutdown(); }
void depthstream::on_connection_removed(astra_bin_t bin, astra_streamconnection_t connection) { PROFILE_FUNC(); devicestream::on_connection_removed(bin, connection); #ifdef __ANDROID__ PROFILE_UPDATE(); PROFILE_OUTPUT("/sdcard/profile_openni_sensor.txt"); #endif }
//------------------------------------------------------------ //------------------------------------------------------------ void GameState::OnDestroy() { m_scoreChangedConnection.reset(); // update all profiles PROFILE_UPDATE(); // create directory for profiling (won't create it if it already exists) bool isCreated = CSCore::Application::Get()->GetFileSystem()->CreateDirectoryPath(CSCore::StorageLocation::k_saveData, "Profile"); if (isCreated) { // get both parts of profile string std::string profileStr = PROFILE_GET_FLAT_STRING(); profileStr.append("\n\n"); profileStr.append(PROFILE_GET_TREE_STRING()); // write profile bool isWritten = CSCore::Application::Get()->GetFileSystem()->WriteFile(CSCore::StorageLocation::k_saveData, "Profile/cspong_profile.txt", profileStr); if (!isWritten) { CS_LOG_ERROR("PROFILING OUTPUT: Failed to write profile file to SaveData/Profile/cspong_profile.txt"); } else { CS_LOG_VERBOSE("PROFILING OUTPUT: Saved profile file to SaveData/Profile/cspong_profile.txt"); } } else { CS_LOG_ERROR("PROFILING OUTPUT: Failed to create directory path for SaveData/Profile"); } }
bool GameManager::update() { #ifdef CHOWDREN_USE_DYNAMIC_NUMBER static int save_time = 0; save_time--; if (save_time <= 0) { save_alterable_debug(); save_time += 60; } #endif #ifdef SHOW_STATS bool show_stats = false; static int measure_time = 0; measure_time -= 1; if (measure_time <= 0) { measure_time = 200; show_stats = true; } #endif #ifdef CHOWDREN_USER_PROFILER static int frame = 0; frame++; std::stringstream ss; ss << "Frame " << frame << ": " << fps_limit.dt << " "; #endif // update input keyboard.update(); mouse.update(); platform_poll_events(); #ifdef CHOWDREN_USE_GWEN gwen.update(); #endif // player controls int new_control = get_player_control_flags(1); player_press_flags = new_control & ~(player_flags); player_flags = new_control; // joystick controls new_control = get_joystick_control_flags(1); joystick_press_flags = new_control & ~(joystick_flags); joystick_release_flags = joystick_flags & ~(new_control); joystick_flags = new_control; #ifdef CHOWDREN_USE_JOYTOKEY for (int i = 0; i < simulate_count; i++) { if (simulate_keys[i].down) { simulate_keys[i].down = false; continue; } keyboard.remove(simulate_keys[i].key); simulate_keys[i] = simulate_keys[simulate_count-1]; i--; simulate_count--; } for (int i = 0; i < CHOWDREN_BUTTON_MAX-1; i++) { int key = key_mappings[i]; if (key == -1) continue; if (is_joystick_pressed_once(1, i+1)) keyboard.add(key); else if (is_joystick_released_once(1, i+1)) keyboard.remove(key); } axis_moved = false; for (int i = 0; i < CHOWDREN_AXIS_MAX-1; i++) { float value = get_joystick_axis(1, i+1); int pos = axis_pos_mappings[i]; int neg = axis_neg_mappings[i]; int axis_value = 0; if (value > deadzone) { last_axis = i; if (pos != -1 && axis_values[i] != 1) keyboard.add(pos); axis_value = 1; } else { if (pos != -1 && axis_values[i] == 1) keyboard.remove(pos); } if (value < -deadzone) { last_axis = i; if (neg != -1 && axis_values[i] != -1) keyboard.add(neg); axis_value = -1; } else { if (neg != -1 && axis_values[i] == -1) keyboard.remove(neg); } axis_values[i] = axis_value; static bool last_move = false; bool new_move = axis_value != 0; if (new_move && new_move != last_move) axis_moved = true; last_move = new_move; } static bool last_connected = false; bool connected = is_joystick_attached(1); pad_selected = connected && last_connected != connected; pad_disconnected = !connected && last_connected != connected; last_connected = connected; #endif // update mouse position platform_get_mouse_pos(&mouse_x, &mouse_y); #ifdef SHOW_STATS if (show_stats) std::cout << "Framerate: " << fps_limit.current_framerate << std::endl; #endif if (platform_has_error()) { if (platform_display_closed()) return false; } else { double event_update_time = platform_get_time(); int ret = update_frame(); #ifdef CHOWDREN_USER_PROFILER ss << (platform_get_time() - event_update_time) << " "; #endif #ifdef SHOW_STATS if (show_stats) std::cout << "Event update took " << platform_get_time() - event_update_time << std::endl; #endif if (ret == 0) return false; else if (ret == 2) return true; if (platform_display_closed()) return false; } double draw_time = platform_get_time(); draw(); #ifdef CHOWDREN_USER_PROFILER ss << (platform_get_time() - draw_time) << " "; #endif #ifdef SHOW_STATS if (show_stats) { std::cout << "Draw took " << platform_get_time() - draw_time << std::endl; #ifndef NDEBUG print_instance_stats(); #endif platform_print_stats(); } #endif fps_limit.finish(); #ifdef CHOWDREN_USER_PROFILER ss << "\n"; std::string logline = ss.str(); user_log.write(&logline[0], logline.size()); #endif #ifdef CHOWDREN_USE_PROFILER static int profile_time = 0; profile_time -= 1; if (profile_time <= 0) { profile_time += 500; PROFILE_UPDATE(); PROFILE_OUTPUT("data:/profile.txt"); } #endif return true; }
void oni_adapter_plugin::temp_update() { PROFILE_FUNC(); read_streams(); PROFILE_UPDATE(); }