Closed georgewsinger closed 5 years ago
:heavy_check_mark: Simula surfaces now launch as squares. Just pushed the code.
Fixing the root cause of this problem. Forcing windows to spawn as squares is a short-term solution. The root cause is tweaking our window movement mechanics. @lboklin in Simula chat:
Re: rotational issues for rectangular windows: I think the solution is to change the physics/mechanics to work properly. It's probably my rotation math that is bad in some place
@lboklin, I'm assuming the relevant piece of code to tweak is:
manipulate :: Bool -> Float -> Telekinesis -> IO Telekinesis
manipulate isMove factor tk = do
tf@(TF bs pos) <- tk & _tkController & G.get_global_transform >>= fromLowLevel
tk
& _tkBody
& \case
Just (body, _) -> do
mass <- G.get_mass body
weight <- G.get_weight body
let
TF lastBs lastPos = _tkLastTransform tk
power = mass * factor * factor * _tkStrength tk :: Float
tScale = 0.01 -- Too sensitive otherwise
-- Angular impulse around each axis
tImpX = cross (lastBs ^. _z) (bs ^. _z) ^* power * tScale
tImpY = cross (lastBs ^. _x) (bs ^. _x) ^* power * tScale
tImpZ = cross (lastBs ^. _y) (bs ^. _y) ^* power * tScale
-- Linear impulse
lImp = power *^ (pos - lastPos)
totalImp =
if isMove then norm $ tImpX + tImpY + tImpZ + lImp else 0
rumble = 0.001 * (weight + totalImp)
when isMove $ do
G.apply_torque_impulse body =<< toLowLevel tImpX
G.apply_torque_impulse body =<< toLowLevel tImpY
G.apply_torque_impulse body =<< toLowLevel tImpZ
p <- toLowLevel zero
G.apply_impulse body p =<< toLowLevel lImp
return tk { _tkLastTransform = tf, _tkRumble = rumble }
Nothing -> return tk { _tkLastTransform = tf, _tkRumble = 0 }
It would be nice if we could figure out a way to change these variables live in the Godot editor to accelerate the iteration feedback loop.
Some windows (i.e.,
firefox
&midori
) launch too rectangularly (i.e., aspect ratios too far away from1
), which causes them to rotate awkwardly with our current levitation mechanics: