/* ARGSUSED */ void lcollection_update_zone(lcollection_update_type_t ut, void(*update_notification_cb)(char *, char *, int, uint64_t, int)) { int i; uint_t nzents; zone_entry_t *zents; /* * Enumerate running zones. */ if (get_running_zones(&nzents, &zents) != 0) return; for (i = 0; i < nzents; i++) { update_zone(&zents[i], (void *)update_notification_cb); } free(zents); }
void scene_view::add_zone(const zone &z) { m_zones.push_back(z); m_zones_internal.push_back({}); update_zone(z, m_zones_internal.back()); }
void scene_view::paintGL() { const float height = m_location_phys.get_height(m_camera_pos.x, m_camera_pos.z, false); nya_scene::get_camera_proxy()->set_rot(m_camera_yaw, m_camera_pitch, 0.0f); nya_scene::get_camera_proxy()->set_pos(pos_h(m_camera_pos, height)); nya_render::clear(true, true); m_location.update_tree_texture(); m_location.draw(); for (auto &o: m_objects) draw(o); m_cursor_pos = world_cursor_pos(); if (m_mode == mode_add) { m_selected_add.pos = m_cursor_pos; draw(m_selected_add); } m_dd.clear(); if (m_mode == mode_zone) { m_zone_add.pos = m_cursor_pos; static zone_internal zi; update_zone(m_zone_add, zi); add_to_draw(zi, red); } const auto &sel_zones = m_selection["zones"]; int idx = 0; for (auto &z: m_zones_internal) { auto color = (m_mode == mode_edit && sel_zones.find(idx++) != sel_zones.end()) ? red : green; if (m_mode != mode_zone && m_mode != mode_edit) color.w *= 0.3f; add_to_draw(z, color); } const auto &sel_paths = m_selection["paths"]; idx = 0; for (auto &p: m_paths) { auto color = (m_mode == mode_edit && sel_paths.find(idx++) != sel_paths.end()) ? red : yellow; if (m_mode != mode_path && m_mode != mode_edit) color.w *= 0.3f; for (int i = 0; i < (int)p.points.size(); ++i) { auto &p0 = p.points[i]; m_dd.add_point(pos_h(p0.xyz(), p0.w), color); m_dd.add_line(pos_h(p0.xyz(), p0.w), p0.xyz(), color * 0.7); if (i > 0) { auto &p1 = p.points[i - 1]; m_dd.add_line(pos_h(p0.xyz(), p0.w), pos_h(p1.xyz(), p1.w), color); } } } if (m_mode == mode_path) { auto p1 = pos_h(m_cursor_pos, m_selected_add.y); if (!sel_paths.empty()) { int idx = *sel_paths.rbegin(); if (idx < (int)m_paths.size() && !m_paths[idx].points.empty()) { auto &p0 = m_paths[idx].points.back(); m_dd.add_line(pos_h(p0.xyz(), p0.w), p1, red); } } m_dd.add_line(m_cursor_pos, p1, red); m_dd.add_point(p1, red); } const auto &sel_objects = m_selection["objects"]; idx = 0; for (auto &o: m_objects) { auto color = green; auto &a = o.attributes["align"]; if (a == "ally") color = blue; else if (a == "neutral") color = white; if ((m_mode == mode_edit && sel_objects.find(idx++) != sel_objects.end())) color = red; if (m_mode != mode_add && m_mode != mode_edit) color.w *= 0.3f; m_dd.add_line(o.pos, pos_h(o.pos, o.y), color); m_dd.add_point(o.pos, color); } if (m_mode == mode_add) { m_dd.add_line(m_cursor_pos, m_cursor_pos + nya_math::vec3(0, m_selected_add.y, 0), red); m_dd.add_point(m_cursor_pos, red); } auto color = (m_mode == mode_edit && !m_selection["player spawn"].empty()) ? red : blue; if (m_mode != mode_add && m_mode != mode_edit) color.w *= 0.3f; auto player_up = m_player.pos + nya_math::vec3(0, m_player.y, 0); m_dd.add_line(m_player.pos, player_up, color); m_dd.add_point(m_player.pos, color); auto player_fw = nya_math::vec2(0.0f, 1.0f).rotate(-m_player.yaw) * 4.0f; auto player_fw3 = nya_math::vec3(player_fw.x, 0, player_fw.y) * 2.0; m_dd.add_line(player_up - player_fw3, player_up + player_fw3, color); nya_math::vec3 player_r3(player_fw.y, 0, -player_fw.x); m_dd.add_line(player_up + player_fw3, player_up + player_r3, color); m_dd.add_line(player_up + player_fw3, player_up - player_r3, color); nya_render::set_state(nya_render::state()); nya_render::depth_test::disable(); nya_render::blend::enable(nya_render::blend::src_alpha, nya_render::blend::inv_src_alpha); nya_render::set_modelview_matrix(nya_scene::get_camera().get_view_matrix()); m_dd.draw(); }