MCPcopy Create free account
hub / github.com/WolfireGames/overgrowth / Update

Method Update

Source/Editors/map_editor.cpp:1131–1285  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1129}
1130
1131void MapEditor::Update(GameCursor* cursor) {
1132 if (!Engine::Instance()->menu_paused) {
1133 // Update editor mouseray
1134 LineSegment mouseray;
1135 GetMouseRay(&mouseray);
1136
1137 if (state_ == MapEditor::kIdle) { // Update active tool if no action is occuring
1138 Collision mouseray_collision_selected = lineCheckActiveSelected(scenegraph_, mouseray.start, mouseray.end, NULL, NULL);
1139 omni_tool_tool_ = EditorTypes::NO_TOOL;
1140 bool hit_something = mouseray_collision_selected.hit;
1141 if (hit_something) {
1142 ;
1143 Object* hit_what = mouseray_collision_selected.hit_what;
1144 if (hit_what) {
1145 omni_tool_tool_ = OmniGetTool(mouseray_collision_selected, hit_what->permission_flags, hit_what, hit_what->box_);
1146 }
1147 }
1148 }
1149 // Handle sky editor
1150 if (state_ == MapEditor::kSkyDrag || !lineCheckActiveSelected(scenegraph_, mouseray.start, mouseray.end, NULL, NULL).hit) {
1151 vec3 mouseray_dir = normalize(mouseray.end - mouseray.start);
1152 float dst_from_sun = dot(mouseray_dir, sky_editor_->sun_dir_);
1153 if (dst_from_sun <= 1.0f && dst_from_sun >= 0.0f) {
1154 float angle_from_sun = acosf(dst_from_sun);
1155
1156 // Check if we've double-clicked on the sun
1157 if (!sky_editor_->HandleSelect(angle_from_sun)) {
1158 // Get relevant tool based on mouse position
1159 if (!sky_editor_->m_sun_translating && !sky_editor_->m_sun_scaling && !sky_editor_->m_sun_rotating) {
1160 sky_editor_->m_tool = sky_editor_->OmniGetTool(angle_from_sun, mouseray);
1161 }
1162 // Handle the activated tool
1163 if (!sky_editor_->m_sun_scaling && !sky_editor_->m_sun_rotating && sky_editor_->m_tool == EditorTypes::TRANSLATE) sky_editor_->HandleSunTranslate(angle_from_sun);
1164 if (!sky_editor_->m_sun_translating && !sky_editor_->m_sun_rotating && sky_editor_->m_tool == EditorTypes::SCALE) sky_editor_->HandleSunScale(angle_from_sun);
1165 if (!sky_editor_->m_sun_translating && !sky_editor_->m_sun_scaling && sky_editor_->m_tool == EditorTypes::ROTATE) sky_editor_->HandleSunRotate(angle_from_sun, mouseray_dir, cursor);
1166 }
1167 }
1168 }
1169 if (!CheckForSelections(mouseray)) {
1170 if (state_ == MapEditor::kIdle) {
1171 HandleShortcuts(mouseray);
1172 }
1173 UpdateTools(mouseray, cursor);
1174 }
1175 // Update cursor
1176 if (state_ == MapEditor::kIdle) {
1177 UpdateCursor(mouseray, cursor);
1178 }
1179 }
1180
1181 if (color_history_countdown_) {
1182 color_history_countdown_--;
1183 if (color_history_countdown_ == 0) {
1184 int found_index = -1;
1185 for (int i = 0; i < kColorHistoryLen; ++i) {
1186 bool closeEnough = true;
1187
1188 for (int j = 0; j < 4; ++j) {

Callers

nothing calls this directly

Calls 15

GetMouseRayFunction · 0.85
lineCheckActiveSelectedFunction · 0.85
OmniGetToolFunction · 0.85
HandleSelectMethod · 0.80
OmniGetToolMethod · 0.80
HandleSunTranslateMethod · 0.80
HandleSunScaleMethod · 0.80
HandleSunRotateMethod · 0.80
normalizeFunction · 0.50
dotFunction · 0.50
acosfFunction · 0.50
beginMethod · 0.45

Tested by

no test coverage detected