Ezriilc / HyperEdit

A plugin for Kerbal Space Program.
http://www.Kerbaltek.com/hyperedit
GNU General Public License v3.0
41 stars 31 forks source link

Spinning skybox after teleporting to orbit another body #4

Open Sigma88 opened 9 years ago

Sigma88 commented 9 years ago

I'm having a bug with HyperEdit. I'm pretty sure it's hyperedit since I've been able to reproduce it with a clean KSP 1.0.4 install with only Hyper Edit (not even MM)

to reproduce the bug:

1- from the KSC click on the launch pad and select Kerbal 2 (Stock) then press launch 2- using hyper edit's orbit editor (Simple) set altitude to 1000000 and reference body Duna (works with EVE, Jool too. probably works with every planet. I didn't check them all) 3- after your ship moved time warp, it works with any level of time warp. but higher time warp are worst 4- look at the skybox go crazy

I think this is related to hyperediting a landed ship directly to orbit and maybe even related to this KSP feature

http://bugs.kerbalspaceprogram.com/issues/5234

If you need logs let me know

btw, to fix the bug: 5- turn off time warp 6- quicksave and quickload and the problem is gone

Ezriilc commented 9 years ago

I am unable to reproduce this, or I am misunderstanding the issue. When I follow the steps given, I do see what appears to be slow rotation of the craft being amplified by the time-warp, but nothing going crazy. I plan to do a fresh download and install and retry.

Sigma88 commented 9 years ago

try maximum time-warp. ships shouldn't rotate in time warp :) I don't know how to make a video, but it's pretty intense. at maximum timewarp the ship is spinning the full 360° more than 1 time each real life second

oh, and thanks for the quick reply :+1:

seems kind of odd nobody has ever noticed this before... (me included)

Sigma88 commented 8 years ago

it seems that this bug is getting worse now, I think the cause is the fact that KSP uses 2 different frames of reference under 100km the reference frame is tied to the planet's rotation while over 100km it's a fixed reference frame.

this means that when you HE from landed (rotational reference frame) to orbit either kerbin at > 100km or any other planet, the reference frame will still be tied to kerbin's rotation and everything will become wonky

quicksaving and reloading resets the reference frame and fixes the issue

if you manage to solve this, be warned that: 1- jool has a different threshold than other planets (1000 km instead of 100km) 2- Kopernicus can change that threshold for stock and/or custom planets

Poodmund commented 8 years ago

Maybe a related issue?

If I try to edit a ship from landed to orbit the craft almost immediately loses its orbit and the vessel is thought to be destroyed. If you switch to Map Mode the orbit lines are gone and after going to the Space Center the vessel is gone.

Reproduction steps, launch Mk1 lander to the pad, edit the craft to be in orbit. The craft should then lose its orbit and "get destroyed". The camera goes a bit funky too. Here's an album of me doing the above: http://imgur.com/a/4y7Ef

If you quicksave immediately after editing the orbit, then reload it all seems to be fine however.

Side note: Not have an issue previously with 1.0 but 1.1 and 1.2 seemed to have induced awareness of this issue to me.

Ezriilc commented 8 years ago

I don't think this particular issue is related. It's very old and should have been closed. However, I think there is something going on now, so I'll leave this open.

Sigma88 commented 8 years ago

the issue is still there, are you closing this because you think it would be too complicated to fix?

just asking, no fuss

(I'm talking about the issue I first reported, not pood's)

Ezriilc commented 8 years ago

No, I just didn't know if it was still there, and I'm not used to working with others in a repo.

Ezriilc commented 8 years ago

I'm currently in no position to fix or even chase this bug, but I am slowly learning the API. So, no projected time can be given, sorry.

Sigma88 commented 8 years ago

no problem! if you need any help to reproduce the issue let me know.

basically what is going on is: KSP uses 2 different frame of reference. a fixed one and a rotational one.

the fixed one is used in space while the rotational is used near planets.

the altitude threshold where the rotational reference frame kicks in is 100000 meters for most planets, it can be changed with kopernicus, the variable is called inverseRotThresholdAltitude

when you hyperedit from kerbin landed to another planet's orbit, ksp still uses the rotational reference frame linked to kerbin, so the ship flips weirdly.

when you quicksave and quickload, ksp recalculates the reference frame and so the spinning stops

I guess that if you can manage to trigger a reference frame recalculation it would fix this issue.

sadly I have no idea how you would go about doing that :|

I hope this can help you :+1:

Ezriilc commented 8 years ago

As I'm currently under the hood of HyperEdit and figuring it out, it does actually help - thanks.

Are you sure you're using the latest of both KSP and HyperEdit? Just to be sure.

Sigma88 commented 8 years ago

yes, this hyperedit and latest ksp (1.1.3)

Ezriilc commented 8 years ago

I am still unable to make this happen. I've used Orbit Editor to put me around Mun at 200km and 20km with no undue effects.

Sigma88 commented 8 years ago

try duna, or eeloo 250km altitude

-from KSC, click on the tracking station and put on the pad a "Kerbal 2" -while still on the pad, use HyperEdit to go to Eeloo (or Duna) 250 km altitude -put the camera on "locked" -time warp at max speed, you will see the skybox spinning

if you quicksave and quickload, put the camera on lock, and time-warp, you won't see the skybox spinning

of course is not the skybox which is spinning, it's the craft. using locked allowes you to be fixed on the craft so that you can track any movement relative to the skybox

Ezriilc commented 8 years ago

AHA! Now I get it. Yep, that's wrong. I'll leave this open until I know enough to get it fixed.

Sigma88 commented 8 years ago

feel free to ping me any time you may need help. you can also find me on the IRC channel for kopernicus ( #kopernicus on irc.espernet.net)

Ezriilc commented 8 years ago

Now I'm hunting for a property to set to fix this. By simply guessing, I suspect it's in vessel, but not everything is documented. I'm looking here: https://docuwiki-kspapi.rhcloud.com/#/classes/Vessel

Any help with this effort is greatly appreciated.

Ezriilc commented 8 years ago

So, I'm doing a test to see the value of FlightGlobals.RefFrameIsRotating, and it's reporting FALSE, but I'm not sure if this is the right thing to be checking.

Ezriilc commented 8 years ago

Correction: It reports TRUE at first, then immediately goes to FALSE.

Ezriilc commented 8 years ago

I also get FALSE for newOrbit.referenceBody.inverseRotation, which seems related to inverseRotThresholdAltitude.

So, at this point, I'm kinda stumped.

Sigma88 commented 8 years ago

I don't really know much about that stuff, I usually ask @nathankell :)

NathanKell commented 8 years ago

each frame OrbitPhysicsManager will set the body to inverse rot if you're below the inverse rot threshold, or to non-inverse rot if above. Probably what's happening is it's an off-by-a-frame condition?

Ezriilc commented 8 years ago

NathanKell, thank you for coming in to help! I was going to wait until Monday to bother you.

I'm sorry, but I'm still pretty new at this, and I don't understand "it's an off-by-a-frame condition". Is that something I can check and/or fix in our code?

Ezriilc commented 8 years ago

Apparently, this issue isn't unique to HyperEdit, and is being caused by something in KSP/Unity itself. As soon as it is figured out, we'll be notified. I'll wait until then to close this.

Sigma88 commented 8 years ago

ok, feel free to close it if you cannot fix it :+1:

Ezriilc commented 8 years ago

I'm reasonably sure that we'll figure some way to fix or get around it one way or another, eventually.

Ezriilc commented 8 years ago

It appears this has been fixed in KSP v1.2 full release. Barring any objections, I will close this issue. @Sigma88?

Sigma88 commented 8 years ago

I just tested this and I can confirm the issue is still there sadly.

steps to reproduce remain the same:

1- load ksp with hyperedit 2- put a "Kerbal 2" craft on the pad 3- while controlling the "Kerbal 2", still attached to the clamps, open hyperedit and go to duna 250000 altitude 4- put the camera on "Locked" 5- while timewarping you will see that the ship rotates against the background

Ezriilc commented 8 years ago

Dang it. I forgot to go to Duna. You're correct, this issue remains. EDIT: Thanks for catching that, @Sigma88

@NathanKell I thought you should know about this.

Sigma88 commented 8 years ago

@Ezriilc no problem!

This is a quick description of what I think is causing the bug, to bring up to speed new people that find this issue.

HOW TO REPRODUCE 1- load ksp with hyperedit 2- put a "Kerbal 2" craft on the pad 3- while controlling the "Kerbal 2", still attached to the clamps, open hyperedit and go to duna 250000 altitude 4- put the camera on "Locked" 5- while timewarping you will see that the ship rotates against the background

POSSIBLE CAUSES I believe there is some kind of tag linked to the position of the craft, when you hyperedit from landed to in space this tag is not updated correctly. I believe the issue is also linked to the difference in reference frame KSP uses while close to a planet (<100km) vs far away (>100km) In this particular case, the issue looks like the craft orientation is calculated using Kerbin's reference frame. and since Duna and Kerbin are different it results in the craft seemingly rotating.

The issue goes away if you save-reload. This means the tag is not maintained through saves.

fronbow commented 6 years ago

I can't reproduce this bug so it might be worth closing @Ezriilc ?

Ezriilc commented 6 years ago

Ah, very good. I keep forgetting to test this.

Basic0 commented 5 years ago

FWIW Not only does this bug still exist, but it appears to have either become worse or have an unreported symptom;

After warping to Duna, I had the ship rotating slowly issue (magnified when warping) but I also noticed my ship was drifting infinitessimally relative to the parent body.

This manifested as an interplanetary hohmann transfer constantly "slipping" meaning the intercept point would drift, even when warping on rails. I could exit warp, thrust and correct, but it would re-manifest when warping again.

After entering a planetary SOI, I was still about to observe the drift via KER although I wouldn't have noticed it unless I knew to look.

FWIW The rotation approx 90 degrees around the sun resulted in approximately a 90-degree rotation of the vessel during the warp (nose ended up poining upwards).

Is it possible there's a matrix transformation happening and either a reference to the body, or the "spatial reference frame"¹ in use isn't being updated?

¹ Referring to the multiple scales/orientations of game world KSP uses to simulate space.

Ezriilc commented 5 years ago

Thank you, @Basic0 for all the input. I'm happy to reopen this if you think it's still a problem. I suppose I should do some more testing. If anyone does and learns anything new, please let me know.

Basic0 commented 5 years ago

If I can help at all, please let me know.

I've been able to reproduce in one game, but it was on a huge, complex ship. (600+ parts). I've started a new game and have been trying to re-create a minimal example but I can't reproduce. I'll see if I can localise the problem at all.

Ezriilc commented 5 years ago

Just the testing that you're doing to reproduce it. Every detail of what may cause or avoid it is helpful.

Thanks!

Sigma88 commented 5 years ago

squad hadded their own tool to put a craft into a certain orbit you can just copy that and should be fine

Ezriilc commented 5 years ago

I'll have to take a long look to see if I can do that, as I'm far from expert in C#. No promises.

Basic0 commented 5 years ago

Okay, so a little more digging... If I remove HyperEdit, the issue isn't reproducible. However, if I take the same vessel to a new game with nothing but a few parts mods, I can't reproduce the problem there either.

Whhich means it's some interaction between at least two of;

I'll keep plugging away, swapping mods in and out, but considering this is my current mod list;

ToolbarController, KSP-AVC, KerbalEngineerRedux, Scatterer-config, NavBallAdjustor, Scatterer-sunflare, xScience, TextureReplacer, Scatterer, AVP-8kTextures, AstronomersVisualPack, EnvironmentalVisualEnhancements, TweakScale, LoadingScreenManager, BetterBurnTime, ModuleManager, Trajectories, AGExt, Toolbar, ClickThroughBlocker, AutomatedScienceSampler, KerboKatzUtilities, TacFuelBalancer, PreciseManeuver, ThrottleControlledAvionics, AT-Utils, ConfigurableContainers-Core, AlternateResourcePanel, SCANsat, TransferWindowPlanner, TriggerAu-Flags, ContractConfigurator, HyperEdit, KerbalAlarmClock, KAS, KerbalFoundriesContinued, KIS, EasyVesselSwitch, KSPWheel, SafeChute, WorldStabilizer, ALCOR, ALCORIVAPatch, NearFutureConstruction, MechJeb2, RealChute, VesselView, DockingPortAlignmentIndicator, VesselView-UI-RasterPropMonitor, ASETAgency, ASETProps, RasterPropMonitor-Core, B9PartSwitch, CommunityResourcePack, FinalFrontier, KerbalPlanetaryBaseSystems, CommunityCategoryKit, HotSpot

I'd say you've got no chance of reproducting, and should probably close this.