laserkestrel / starmap

Other
0 stars 0 forks source link

Replace probeSearchRadiusPixels to use parsecs #3

Open laserkestrel opened 8 months ago

laserkestrel commented 8 months ago

If you want to make probeSearchRadiusPixels dependent on the scale factor in parsecs, you'll need to adjust it accordingly when the scale factor changes. You can calculate probeSearchRadiusPixels based on the scale factor and the desired radius in parsecs. Here's how you can do it:

Define a variable for probeSearchRadiusParsecs in your LoadConfig class or wherever you store your configuration data. Let's say you add it as a member variable with a setter and getter:

class LoadConfig {
private:
    float scaleFactor;
    float probeSearchRadiusParsecs; // Add this variable

public:
    // Existing methods for scaleFactor and other configurations

    void setProbeSearchRadiusParsecs(float radius) {
        probeSearchRadiusParsecs = radius;
    }

    float getProbeSearchRadiusParsecs() const {
        return probeSearchRadiusParsecs;
    }
};

When you update your scale factor in your LoadConfig object, also update the probeSearchRadiusParsecs based on your desired parsec radius:

LoadConfig config;
config.setScaleFactor(10.0f); // Set your scale factor
config.setProbeSearchRadiusParsecs(5.0f); // Set your probe search radius in parsecs

Modify the code that consumes probeSearchRadiusPixels to calculate it based on the scale factor and probeSearchRadiusParsecs. You will use trigonometry to convert parsecs to pixels, similar to how you calculate star positions:

float probeSearchRadiusParsecs = config.getProbeSearchRadiusParsecs();
float probeSearchRadiusPixels = probeSearchRadiusParsecs * syntheticScalingFactor;

Now, when you change the scale factor, probeSearchRadiusPixels will automatically adjust based on the new scale factor and probe search radius in parsecs. This allows you to have a probe search radius that scales with the overall simulation scale.