Better zoom clamp for planets
This commit is contained in:
@@ -58,6 +58,8 @@ public class Planet extends UnlockableContent{
|
|||||||
public float camRadius;
|
public float camRadius;
|
||||||
/** Minimum camera zoom value. */
|
/** Minimum camera zoom value. */
|
||||||
public float minZoom = 0.5f;
|
public float minZoom = 0.5f;
|
||||||
|
/** Maximum camera zoom value. */
|
||||||
|
public float maxZoom = 2f;
|
||||||
/** Whether to draw the orbital circle. */
|
/** Whether to draw the orbital circle. */
|
||||||
public boolean drawOrbit = true;
|
public boolean drawOrbit = true;
|
||||||
/** Atmosphere radius adjustment parameters. */
|
/** Atmosphere radius adjustment parameters. */
|
||||||
|
|||||||
@@ -85,6 +85,8 @@ public class PlanetDialog extends BaseDialog implements PlanetInterfaceRenderer{
|
|||||||
state.planet = content.getByName(ContentType.planet, Core.settings.getString("lastplanet", "serpulo"));
|
state.planet = content.getByName(ContentType.planet, Core.settings.getString("lastplanet", "serpulo"));
|
||||||
if(state.planet == null) state.planet = Planets.serpulo;
|
if(state.planet == null) state.planet = Planets.serpulo;
|
||||||
|
|
||||||
|
clampZoom();
|
||||||
|
|
||||||
addListener(new InputListener(){
|
addListener(new InputListener(){
|
||||||
@Override
|
@Override
|
||||||
public boolean keyDown(InputEvent event, KeyCode key){
|
public boolean keyDown(InputEvent event, KeyCode key){
|
||||||
@@ -140,7 +142,7 @@ public class PlanetDialog extends BaseDialog implements PlanetInterfaceRenderer{
|
|||||||
@Override
|
@Override
|
||||||
public boolean scrolled(InputEvent event, float x, float y, float amountX, float amountY){
|
public boolean scrolled(InputEvent event, float x, float y, float amountX, float amountY){
|
||||||
if(event.targetActor == PlanetDialog.this){
|
if(event.targetActor == PlanetDialog.this){
|
||||||
zoom = Mathf.clamp(zoom + amountY / 10f, state.planet.minZoom, 2f);
|
zoom = Mathf.clamp(zoom + amountY / 10f, state.planet.minZoom, state.planet.maxZoom);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -155,7 +157,7 @@ public class PlanetDialog extends BaseDialog implements PlanetInterfaceRenderer{
|
|||||||
lastZoom = zoom;
|
lastZoom = zoom;
|
||||||
}
|
}
|
||||||
|
|
||||||
zoom = (Mathf.clamp(initialDistance / distance * lastZoom, state.planet.minZoom, 2f));
|
zoom = (Mathf.clamp(initialDistance / distance * lastZoom, state.planet.minZoom, state.planet.maxZoom));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -396,6 +398,8 @@ public class PlanetDialog extends BaseDialog implements PlanetInterfaceRenderer{
|
|||||||
//TODO should this even set `state.planet`? the other lookAt() doesn't, so...
|
//TODO should this even set `state.planet`? the other lookAt() doesn't, so...
|
||||||
state.planet = sector.planet;
|
state.planet = sector.planet;
|
||||||
sector.planet.lookAt(sector, state.camPos);
|
sector.planet.lookAt(sector, state.camPos);
|
||||||
|
|
||||||
|
clampZoom();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void lookAt(Sector sector, float alpha){
|
public void lookAt(Sector sector, float alpha){
|
||||||
@@ -403,6 +407,10 @@ public class PlanetDialog extends BaseDialog implements PlanetInterfaceRenderer{
|
|||||||
state.camPos.slerp(sector.planet.lookAt(sector, Tmp.v33).setLength(len), alpha);
|
state.camPos.slerp(sector.planet.lookAt(sector, Tmp.v33).setLength(len), alpha);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void clampZoom(){
|
||||||
|
zoom = Mathf.clamp(zoom, state.planet.minZoom, state.planet.maxZoom);
|
||||||
|
}
|
||||||
|
|
||||||
boolean canSelect(Sector sector){
|
boolean canSelect(Sector sector){
|
||||||
if(mode == select) return sector.hasBase() && launchSector != null && sector.planet == launchSector.planet;
|
if(mode == select) return sector.hasBase() && launchSector != null && sector.planet == launchSector.planet;
|
||||||
|
|
||||||
@@ -872,6 +880,8 @@ public class PlanetDialog extends BaseDialog implements PlanetInterfaceRenderer{
|
|||||||
newPresets.clear();
|
newPresets.clear();
|
||||||
state.planet = planet;
|
state.planet = planet;
|
||||||
|
|
||||||
|
clampZoom();
|
||||||
|
|
||||||
selected = null;
|
selected = null;
|
||||||
updateSelected();
|
updateSelected();
|
||||||
rebuildExpand();
|
rebuildExpand();
|
||||||
|
|||||||
Reference in New Issue
Block a user