~starkingdoms/starkingdoms

2e1aa7be2e2829b9f15f99bbc851cf1768026f5a — core 17 days ago 7f8769e
feat: solver optimization (pro tip: do not do io in the hot path)
1 files changed, 0 insertions(+), 19 deletions(-)

M crates/unified/src/client/ship/thrusters.rs
M crates/unified/src/client/ship/thrusters.rs => crates/unified/src/client/ship/thrusters.rs +0 -19
@@ 211,9 211,6 @@ fn solve_thrust(
                1.0 // if it's positive, force to +1
            };

            // TODO(core): remove overly verbose debug logging
            trace!("thruster: {:?} {}({})", thruster_vector, thruster_torque, renormalized_thruster_torque);

            // Then, push all this data for the next section to deal with.
            all_thrusters.push((thruster_id,
                                thruster_vector.extend(0.0),


@@ 242,9 239,6 @@ fn solve_thrust(
    "Coefficients" are i_0 ... i_n, and can be precomputed, and x_0 ... x_n is the "decision variables"
     */

    // TODO(core): Remove overly verbose debug logging
    trace!("found {} thrusters, computing coefficients", all_thrusters.len());

    if all_thrusters.len() == 0 {
        trace!("there are no thrusters; zeroing thrust solution");
        trace!("solved thrust in {}ms", start.elapsed().as_millis());


@@ 253,15 247,8 @@ fn solve_thrust(
        return;
    }

    // TODO(core): Remove overly verbose debug logging
    for thruster in &all_thrusters {
        trace!("thruster on ship: {:?}", thruster);
    }

    let coefficients = all_thrusters.iter()
        .map(|u| {
            // TODO(core): Remove overly verbose debug logging
            trace!("{} dot {}, {} dot {}", target_unit_vector, u.1.normalize(), target_torque_vector, u.2.normalize());
            // Computes both system coefficients, for simplicity
            (
                target_unit_vector.dot(u.1.normalize()), // Thrust coefficient


@@ 269,9 256,6 @@ fn solve_thrust(
            )
        })
        .map(|u| {
            // TODO(core): Remove overly verbose debug logging
            trace!("=> {}, {}", u.0, u.1);

            // improve reliability:
            // if thrust coefficient is <0.1, zap it entirely (this thruster is not helping)
            // This is done elsewhere for torque, so pass it (u.1) through unchanged


@@ 380,9 364,6 @@ fn solve_thrust(
    };

    for thruster in all_thrusters.iter().enumerate() {
        // TODO(core): Remove overly verbose debug logging
        trace!("thrust solution: thruster #{} ({:?}): {} @ coeff {}", thruster.0, thruster.1.0, thrust_solution.value(variables[thruster.0].0.1), coefficients[thruster.0].0);
        trace!("torque solution: thruster #{} ({:?}): {} @ coeff {}", thruster.0, thruster.1.0, torque_solution.value(variables[thruster.0].1.1), coefficients[thruster.0].1);
        // TODO(core): make this more easily adjustable

        // Currently, we only turn on a thruster if it's variable value (think weight in a weighted sum)