Body and stars

The place to discuss creating, porting and modifying Celestia's source code.
Topic author
doctorjoe
Posts: 76
Joined: 23.05.2005
With us: 19 years 6 months
Location: Austin, Texas

Body and stars

Post #1by doctorjoe » 26.06.2005, 04:06

Unifying bodies and stars shouldn't take up any extra space.

Body would be an abstract base class, which takes up no memory

class Body {
float getRadius();
}

class Star {
float getRadius() {calculate from spectral type;}
}

class Planet {
float getRadius() {return value};
}

This is an example of the flyweight pattern.

Also in replacing dispatch I was thinking in terms of virtual functions. Using RTTI doesn't get you very much advantage over including a type field.

Return to “Development”