Only editable objects initiate editing state when using edit tool
This commit is contained in:
parent
56b3c27401
commit
762016be4c
2 changed files with 9 additions and 12 deletions
|
|
@ -92,6 +92,10 @@ void EditTool::edit_start(const std::shared_ptr<DrawComponent>& comp) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool EditTool::is_editable(const std::shared_ptr<DrawComponent>& comp) {
|
||||||
|
return comp->get_type() != DRAWCOMPONENT_BRUSHSTROKE;
|
||||||
|
}
|
||||||
|
|
||||||
void EditTool::tool_update() {
|
void EditTool::tool_update() {
|
||||||
if(!controls.isEditing) {
|
if(!controls.isEditing) {
|
||||||
SCollision::AABB<WorldScalar> mouseAABB{drawP.world.get_mouse_world_pos() - WorldVec{0.5f, 0.5f}, drawP.world.get_mouse_world_pos() + WorldVec{0.5f, 0.5f}};
|
SCollision::AABB<WorldScalar> mouseAABB{drawP.world.get_mouse_world_pos() - WorldVec{0.5f, 0.5f}, drawP.world.get_mouse_world_pos() + WorldVec{0.5f, 0.5f}};
|
||||||
|
|
@ -105,25 +109,17 @@ void EditTool::tool_update() {
|
||||||
camCMouseAABB.recalculate_bounds();
|
camCMouseAABB.recalculate_bounds();
|
||||||
|
|
||||||
if(drawP.controls.leftClick) {
|
if(drawP.controls.leftClick) {
|
||||||
|
bool modifySelection = !drawP.selection.is_being_transformed();
|
||||||
if(drawP.world.main.input.mouse.leftClicks >= 2 && !drawP.world.main.input.key(InputManager::KEY_GENERIC_LSHIFT).held && !drawP.world.main.input.key(InputManager::KEY_GENERIC_LALT).held) {
|
if(drawP.world.main.input.mouse.leftClicks >= 2 && !drawP.world.main.input.key(InputManager::KEY_GENERIC_LSHIFT).held && !drawP.world.main.input.key(InputManager::KEY_GENERIC_LALT).held) {
|
||||||
CollabListType::ObjectInfoPtr selectedObjectToEdit = drawP.selection.get_front_object_colliding_with(camCMouseAABB);
|
CollabListType::ObjectInfoPtr selectedObjectToEdit = drawP.selection.get_front_object_colliding_with(camCMouseAABB);
|
||||||
|
|
||||||
if(selectedObjectToEdit) {
|
if(selectedObjectToEdit && is_editable(selectedObjectToEdit->obj)) {
|
||||||
drawP.selection.deselect_all();
|
drawP.selection.deselect_all();
|
||||||
edit_start(selectedObjectToEdit->obj);
|
edit_start(selectedObjectToEdit->obj);
|
||||||
}
|
modifySelection = false;
|
||||||
else {
|
|
||||||
if(drawP.world.main.input.key(InputManager::KEY_GENERIC_LSHIFT).held)
|
|
||||||
drawP.selection.add_from_cam_coord_collider_to_selection(camCMouseAABB, true);
|
|
||||||
else if(drawP.world.main.input.key(InputManager::KEY_GENERIC_LALT).held)
|
|
||||||
drawP.selection.remove_from_cam_coord_collider_to_selection(camCMouseAABB, true);
|
|
||||||
else {
|
|
||||||
drawP.selection.deselect_all();
|
|
||||||
drawP.selection.add_from_cam_coord_collider_to_selection(camCMouseAABB, true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(!drawP.selection.is_being_transformed()) {
|
if(modifySelection) {
|
||||||
if(drawP.world.main.input.key(InputManager::KEY_GENERIC_LSHIFT).held)
|
if(drawP.world.main.input.key(InputManager::KEY_GENERIC_LSHIFT).held)
|
||||||
drawP.selection.add_from_cam_coord_collider_to_selection(camCMouseAABB, true);
|
drawP.selection.add_from_cam_coord_collider_to_selection(camCMouseAABB, true);
|
||||||
else if(drawP.world.main.input.key(InputManager::KEY_GENERIC_LALT).held)
|
else if(drawP.world.main.input.key(InputManager::KEY_GENERIC_LALT).held)
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,7 @@ class EditTool : public DrawingProgramToolBase {
|
||||||
|
|
||||||
void add_point_handle(const HandleData& handle);
|
void add_point_handle(const HandleData& handle);
|
||||||
void edit_start(const std::shared_ptr<DrawComponent>& comp);
|
void edit_start(const std::shared_ptr<DrawComponent>& comp);
|
||||||
|
bool is_editable(const std::shared_ptr<DrawComponent>& comp);
|
||||||
|
|
||||||
struct EditControls {
|
struct EditControls {
|
||||||
std::unique_ptr<DrawingProgramEditToolBase> compEditTool;
|
std::unique_ptr<DrawingProgramEditToolBase> compEditTool;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue