Started work on removing the zoom in limit

This commit is contained in:
Yousef Khadadeh 2025-09-30 11:45:03 +03:00
parent ffcf0e94ab
commit 094fce776f
16 changed files with 78 additions and 23 deletions

View file

@ -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));
}
}
}

View file

@ -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);