Started work on removing the zoom in limit
This commit is contained in:
parent
ffcf0e94ab
commit
094fce776f
16 changed files with 78 additions and 23 deletions
|
|
@ -60,3 +60,8 @@ const std::vector<std::string>& BookmarkManager::sorted_names() {
|
|||
const std::unordered_map<std::string, Bookmark>& BookmarkManager::bookmark_list() {
|
||||
return bookmarks;
|
||||
}
|
||||
|
||||
void BookmarkManager::scale_up(const WorldScalar& scaleUpAmount) {
|
||||
for(auto& [n, b] : bookmarks)
|
||||
b.coords.scale_about(WorldVec{0, 0}, scaleUpAmount, true);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,6 +21,8 @@ class BookmarkManager {
|
|||
void add_bookmark(const std::string& name);
|
||||
void remove_bookmark(const std::string& name);
|
||||
void jump_to_bookmark(const std::string& name);
|
||||
void scale_up(const WorldScalar& scaleUpAmount);
|
||||
|
||||
const std::unordered_map<std::string, Bookmark>& bookmark_list();
|
||||
|
||||
template <typename Archive> void save(Archive& a) const {
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
#include <iostream>
|
||||
|
||||
DrawCamera::DrawCamera():
|
||||
c({0, 0}, WorldScalar(1000000), 0.0)
|
||||
c({0, 0}, WorldScalar(10), 0.0)
|
||||
//c({-843000, -72500}, WorldScalar(1000), 0.0)
|
||||
//c({0, 0}, WorldScalar(1000), 0.0)
|
||||
//c({"1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"}, WorldScalar("1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"), 0.0)
|
||||
|
|
@ -55,6 +55,15 @@ void DrawCamera::smooth_move_to(World& w, const CoordSpaceHelper& newCoords, Vec
|
|||
smoothMove.moveTime = (instantJump || w.main.toolbar.jumpTransitionTime <= 0.01f) ? w.main.toolbar.jumpTransitionTime : 0.0f;
|
||||
}
|
||||
|
||||
void DrawCamera::scale_up(World& w, const WorldScalar& scaleUpAmount) {
|
||||
smoothMove.occurring = false;
|
||||
c.scale_about({0, 0}, scaleUpAmount, true);
|
||||
startZoomVal *= scaleUpAmount;
|
||||
startZoomMousePos *= scaleUpAmount;
|
||||
startZoomCameraPos *= scaleUpAmount;
|
||||
set_viewing_area(w.main.window.size.cast<float>());
|
||||
}
|
||||
|
||||
void DrawCamera::update_main(World& w) {
|
||||
if(smoothMove.occurring) {
|
||||
BezierEasing zoomAnim{w.main.toolbar.jumpTransitionEasing};
|
||||
|
|
@ -118,13 +127,9 @@ void DrawCamera::update_main(World& w) {
|
|||
if(isAccurateZooming) {
|
||||
WorldScalar zoomFactor(std::pow(1.0 + w.main.toolbar.dragZoomSpeed, w.main.input.mouse.move.y()));
|
||||
c.scale(zoomFactor);
|
||||
if(c.inverseScale < WorldScalar(1))
|
||||
c.inverseScale = WorldScalar(1);
|
||||
else {
|
||||
WorldVec mVec = startZoomCameraPos - startZoomMousePos;
|
||||
WorldScalar mX = c.inverseScale / startZoomVal;
|
||||
c.pos = startZoomMousePos + mVec * mX;
|
||||
}
|
||||
WorldVec mVec = startZoomCameraPos - startZoomMousePos;
|
||||
WorldScalar mX = c.inverseScale / startZoomVal;
|
||||
c.pos = startZoomMousePos + mVec * mX;
|
||||
}
|
||||
else if(w.drawProg.controls.middleClickHeld || (w.drawProg.controls.leftClickHeld && w.drawProg.drawTool->get_type() == DrawingProgramToolType::PAN))
|
||||
c.pos -= c.dir_from_space(w.main.input.mouse.move);
|
||||
|
|
@ -136,12 +141,8 @@ void DrawCamera::update_main(World& w) {
|
|||
zoomFactor = WorldScalar(1) / zoomFactor;
|
||||
|
||||
c.scale(zoomFactor);
|
||||
if(c.inverseScale < WorldScalar(1))
|
||||
c.inverseScale = WorldScalar(1);
|
||||
else {
|
||||
WorldVec mVec = c.pos - w.get_mouse_world_pos();
|
||||
c.pos = w.get_mouse_world_pos() + mVec / zoomFactor;
|
||||
}
|
||||
WorldVec mVec = c.pos - w.get_mouse_world_pos();
|
||||
c.pos = w.get_mouse_world_pos() + mVec / zoomFactor;
|
||||
}
|
||||
if(w.main.input.key(InputManager::KEY_CAMERA_ROTATE_COUNTERCLOCKWISE).held && !w.main.input.text.get_accepting_input()) {
|
||||
c.rotate_about(c.from_space(w.main.window.size.cast<float>() * 0.5f), -w.main.deltaTime);
|
||||
|
|
@ -152,4 +153,9 @@ void DrawCamera::update_main(World& w) {
|
|||
}
|
||||
|
||||
set_viewing_area(w.main.window.size.cast<float>());
|
||||
|
||||
if(c.inverseScale < WorldScalar(1)) {
|
||||
std::cout << "yes!" << std::endl;
|
||||
w.scale_up(WorldScalar(1000000));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,6 +24,8 @@ class DrawCamera {
|
|||
void set_based_on_properties(World& w, const WorldVec& newPos, const WorldScalar& newZoom, double newRotate);
|
||||
void set_based_on_center(World& w, const WorldVec& newPos, const WorldScalar& newZoom, double newRotate);
|
||||
void update_main(World& main);
|
||||
|
||||
void scale_up(World& w, const WorldScalar& scaleUpAmount);
|
||||
private:
|
||||
struct SmoothMove {
|
||||
CoordSpaceHelper start;
|
||||
|
|
|
|||
|
|
@ -89,7 +89,7 @@ void DrawComponent::remap_resource_ids(std::unordered_map<ServerClientID, Server
|
|||
#ifndef IS_SERVER
|
||||
|
||||
bool DrawComponent::bounds_draw_check(const DrawData& drawData) const {
|
||||
bool a = !drawData.clampDrawBetween || ((drawData.clampDrawMaximum >= coords.inverseScale) && (drawData.clampDrawMinimum < coords.inverseScale));
|
||||
bool a = !drawData.clampDrawBetween || (drawData.clampDrawMinimum < coords.inverseScale);
|
||||
return a;
|
||||
}
|
||||
|
||||
|
|
@ -124,6 +124,11 @@ void DrawComponent::commit_transform(DrawingProgram& drawP, bool invalidateCache
|
|||
drawP.preupdate_component(lockedCollabInfo);
|
||||
}
|
||||
|
||||
void DrawComponent::scale_up(const WorldScalar& scaleUpAmount) {
|
||||
coords.scale_about(WorldVec{0, 0}, scaleUpAmount, true);
|
||||
calculate_world_bounds();
|
||||
}
|
||||
|
||||
void DrawComponent::client_send_place_many(DrawingProgram& drawP, std::vector<CollabListType::ObjectInfoPtr>& comps) {
|
||||
drawP.world.con.client_send_items_to_server(RELIABLE_COMMAND_CHANNEL, SERVER_PLACE_MANY_COMPONENTS, SendOrderedComponentVectorOp{&comps});
|
||||
}
|
||||
|
|
@ -161,7 +166,7 @@ bool DrawComponent::collides_with_cam_coords(const CoordSpaceHelper& camCoords,
|
|||
|
||||
// We could just send one of the checkAgainst colliders, since they represent the same thing, but sending both saves on redundant transformations, since we can save both of the versions on the executor side
|
||||
bool DrawComponent::collides_with(const CoordSpaceHelper& camCoords, const SCollision::ColliderCollection<WorldScalar>& checkAgainstWorld, const SCollision::ColliderCollection<float>& checkAgainstCam) {
|
||||
if((camCoords.inverseScale << DRAWCOMP_MAX_SHIFT_BEFORE_DISAPPEAR) < coords.inverseScale) // Object is too large, just dismiss the collision
|
||||
if((camCoords.inverseScale << DRAWCOMP_MAX_SHIFT_BEFORE_STOP_COLLISIONS) < coords.inverseScale) // Object is too large, just dismiss the collision
|
||||
return false;
|
||||
else if((camCoords.inverseScale >> DRAWCOMP_COLLIDE_MIN_SHIFT_TINY) >= coords.inverseScale) {
|
||||
if(!worldAABB)
|
||||
|
|
@ -199,7 +204,7 @@ void DrawComponent::calculate_draw_transform(const DrawData& drawData) {
|
|||
drawSetupData.mipmapLevel = 0;
|
||||
drawSetupData.transformData.translation = -coords.to_space(drawData.cam.c.pos);
|
||||
drawSetupData.transformData.rotation = (coords.rotation - drawData.cam.c.rotation) * 180.0 / std::numbers::pi;
|
||||
drawSetupData.transformData.scale = std::min(static_cast<float>(coords.inverseScale / drawData.cam.c.inverseScale), static_cast<float>(1 << DRAWCOMP_MAX_SHIFT_BEFORE_DISAPPEAR));
|
||||
drawSetupData.transformData.scale = std::min(static_cast<float>(coords.inverseScale / drawData.cam.c.inverseScale), static_cast<float>(1 << DRAWCOMP_MAX_SHIFT_BEFORE_STOP_SCALING));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,8 @@
|
|||
|
||||
#define CLIENT_DRAWCOMP_DELAY_TIMER_DURATION std::chrono::seconds(6)
|
||||
|
||||
#define DRAWCOMP_MAX_SHIFT_BEFORE_DISAPPEAR 18
|
||||
#define DRAWCOMP_MAX_SHIFT_BEFORE_STOP_COLLISIONS 14
|
||||
#define DRAWCOMP_MAX_SHIFT_BEFORE_STOP_SCALING 18
|
||||
#define DRAWCOMP_MIN_SHIFT_BEFORE_DISAPPEAR 11
|
||||
#define DRAWCOMP_COLLIDE_MIN_SHIFT_TINY 9
|
||||
#define DRAWCOMP_MIPMAP_LEVEL_ONE 2
|
||||
|
|
@ -64,6 +65,9 @@ class DrawComponent {
|
|||
void calculate_draw_transform(const DrawData& drawData);
|
||||
|
||||
void server_send_place(MainServer& server, uint64_t placement);
|
||||
|
||||
void scale_up(const WorldScalar& scaleUpAmount);
|
||||
|
||||
static void server_send_place_many(MainServer& server, std::vector<CollabListType::ObjectInfoPtr>& comps);
|
||||
static void server_send_erase(MainServer& server, ServerClientID id);
|
||||
static void server_send_erase_set(MainServer& server, const std::unordered_set<ServerClientID>& ids);
|
||||
|
|
|
|||
|
|
@ -6,5 +6,4 @@ void DrawData::refresh_draw_optimizing_values() {
|
|||
clampDrawMinimum = cam.c.inverseScale >> DRAWCOMP_MIN_SHIFT_BEFORE_DISAPPEAR;
|
||||
mipMapLevelOne = cam.c.inverseScale >> DRAWCOMP_MIPMAP_LEVEL_ONE;
|
||||
mipMapLevelTwo = cam.c.inverseScale >> DRAWCOMP_MIPMAP_LEVEL_TWO;
|
||||
clampDrawMaximum = cam.c.inverseScale << DRAWCOMP_MAX_SHIFT_BEFORE_DISAPPEAR;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@ struct DrawData {
|
|||
bool clampDrawBetween = true;
|
||||
bool drawGrids = true;
|
||||
WorldScalar clampDrawMinimum;
|
||||
WorldScalar clampDrawMaximum;
|
||||
WorldScalar mipMapLevelOne;
|
||||
WorldScalar mipMapLevelTwo;
|
||||
void refresh_draw_optimizing_values();
|
||||
|
|
|
|||
|
|
@ -147,6 +147,13 @@ void DrawingProgram::init_client_callbacks() {
|
|||
});
|
||||
}
|
||||
|
||||
void DrawingProgram::scale_up(const WorldScalar& scaleUpAmount) {
|
||||
for(auto& c : components.client_list())
|
||||
c->obj->scale_up(scaleUpAmount);
|
||||
selection.deselect_all();
|
||||
force_rebuild_cache();
|
||||
}
|
||||
|
||||
void DrawingProgram::check_delayed_update_timers() {
|
||||
std::erase_if(delayedUpdateComponents, [&](auto& p) {
|
||||
auto& [comp, delayedUpdatePtr] = p;
|
||||
|
|
@ -358,7 +365,7 @@ void DrawingProgram::update() {
|
|||
EraserTool* eraserTool = static_cast<EraserTool*>(drawTool.get());
|
||||
compCache.test_rebuild_dont_include_set_dont_include_nodes(components.client_list(), eraserTool->erasedComponents, eraserTool->erasedBVHNodes);
|
||||
}
|
||||
else if(drawTool->get_type() == DrawingProgramToolType::RECTSELECT)
|
||||
else if(is_selection_tool(drawTool->get_type()))
|
||||
compCache.test_rebuild_dont_include_set(components.client_list(), selection.get_selected_set());
|
||||
else
|
||||
compCache.test_rebuild(components.client_list());
|
||||
|
|
@ -403,7 +410,7 @@ void DrawingProgram::force_rebuild_cache() {
|
|||
EraserTool* eraserTool = static_cast<EraserTool*>(drawTool.get());
|
||||
compCache.test_rebuild_dont_include_set_dont_include_nodes(components.client_list(), eraserTool->erasedComponents, eraserTool->erasedBVHNodes, true);
|
||||
}
|
||||
else if(drawTool->get_type() == DrawingProgramToolType::RECTSELECT || drawTool->get_type() == DrawingProgramToolType::LASSOSELECT)
|
||||
else if(is_selection_tool(drawTool->get_type()))
|
||||
compCache.test_rebuild_dont_include_set(components.client_list(), selection.get_selected_set(), true);
|
||||
else
|
||||
compCache.test_rebuild(components.client_list(), true);
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ class DrawingProgram {
|
|||
void toolbar_gui();
|
||||
void tool_options_gui();
|
||||
void update();
|
||||
void scale_up(const WorldScalar& scaleUpAmount);
|
||||
void draw(SkCanvas* canvas, const DrawData& drawData);
|
||||
void initialize_draw_data(cereal::PortableBinaryInputArchive& a);
|
||||
std::unordered_set<ServerClientID> get_used_resources();
|
||||
|
|
|
|||
|
|
@ -98,3 +98,9 @@ void GridManager::draw_coordinates(SkCanvas* canvas, const DrawData& drawData) {
|
|||
g.coordinatesWillBeDrawn = false;
|
||||
}
|
||||
}
|
||||
|
||||
void GridManager::scale_up(const WorldScalar& scaleUpAmount) {
|
||||
for(auto& [id, g] : grids) {
|
||||
g.scale_up(scaleUpAmount);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,6 +23,8 @@ class GridManager {
|
|||
void remove_grid(ServerClientID idToRemove);
|
||||
void draw(SkCanvas* canvas, const DrawData& drawData);
|
||||
void draw_coordinates(SkCanvas* canvas, const DrawData& drawData);
|
||||
void scale_up(const WorldScalar& scaleUpAmount);
|
||||
|
||||
ClientPortionID get_max_id(ServerPortionID serverID) const;
|
||||
|
||||
const std::vector<ServerClientID>& sorted_grid_ids();
|
||||
|
|
|
|||
|
|
@ -376,7 +376,7 @@ WorldScalar World::calculate_zoom_from_uniform_zoom(WorldScalar uniformZoom, Wor
|
|||
|
||||
void World::draw_other_player_cursors(SkCanvas* canvas, const DrawData& drawData) {
|
||||
for(auto& [id, data] : clients) {
|
||||
if(drawData.clampDrawMaximum > data.camCoords.inverseScale && drawData.clampDrawMinimum < data.camCoords.inverseScale) {
|
||||
if((drawData.cam.c.inverseScale << 10) > data.camCoords.inverseScale && drawData.clampDrawMinimum < data.camCoords.inverseScale) {
|
||||
canvas->save();
|
||||
data.camCoords.transform_sk_canvas(canvas, drawData);
|
||||
|
||||
|
|
@ -407,6 +407,15 @@ void World::draw_other_player_cursors(SkCanvas* canvas, const DrawData& drawData
|
|||
}
|
||||
}
|
||||
|
||||
void World::scale_up(const WorldScalar& scaleUpAmount) {
|
||||
Logger::get().log("USERINFO", "Canvas scaled up");
|
||||
drawProg.scale_up(scaleUpAmount);
|
||||
bMan.scale_up(scaleUpAmount);
|
||||
gridMan.scale_up(scaleUpAmount);
|
||||
drawData.cam.scale_up(*this, scaleUpAmount);
|
||||
undo.clear();
|
||||
}
|
||||
|
||||
void World::draw(SkCanvas* canvas) {
|
||||
drawData.refresh_draw_optimizing_values();
|
||||
if(drawData.drawGrids)
|
||||
|
|
|
|||
|
|
@ -99,7 +99,9 @@ class World {
|
|||
SkColor4f toolFrontColor;
|
||||
} canvasTheme;
|
||||
|
||||
void scale_up(const WorldScalar& scaleUpAmount);
|
||||
private:
|
||||
|
||||
ClientPortionID get_max_id(ServerPortionID serverID);
|
||||
|
||||
void init_client_callbacks();
|
||||
|
|
|
|||
|
|
@ -206,6 +206,11 @@ std::string WorldGrid::get_display_name() {
|
|||
return name.empty() ? "New Grid" : name;
|
||||
}
|
||||
|
||||
void WorldGrid::scale_up(const WorldScalar& scaleUpAmount) {
|
||||
size *= scaleUpAmount;
|
||||
offset *= scaleUpAmount;
|
||||
}
|
||||
|
||||
void WorldGrid::draw(GridManager& gMan, SkCanvas* canvas, const DrawData& drawData) {
|
||||
coordinatesAxisOnBounds = false;
|
||||
coordinatesWillBeDrawn = false;
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@ class WorldGrid {
|
|||
|
||||
void set_remove_divisions_outwards(bool v);
|
||||
void set_subdivisions(uint32_t v);
|
||||
void scale_up(const WorldScalar& scaleUpAmount);
|
||||
|
||||
static unsigned GRID_UNIT_PIXEL_SIZE;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue