]> git.itanic.dy.fi Git - sdl-planets/blobdiff - planet.h
planets: Add quadtrees in use
[sdl-planets] / planet.h
index 4b6d3f42e4d87ec3c1f1ad08578b54dcd425b1e8..22bfd070cb91f699ae8ff24ce1509594b4caaa11 100644 (file)
--- a/planet.h
+++ b/planet.h
@@ -7,11 +7,13 @@
 #include "list.h"
 #include "utils.h"
 #include "camera.h"
+#include "quadtree.h"
 
 struct planet {
        struct vector speed;
        struct vector pos;
        struct list_head list;
+       struct quadtree tree;
        double mass;
        float radius;
        unsigned char r, g, b;
@@ -19,13 +21,16 @@ struct planet {
 
 #define list_to_planet(list_head) container_of((list_head), struct planet, list)
 
+#define tree_to_planet(qt) container_of((qt), struct planet, tree)
+
 void init_planet(struct planet *p);
 void create_planets(struct planet *p, int num, double total_mass,
                    double radius);
 void draw_planet(SDL_Surface *screen, struct planet *p, const struct camera *);
 int gravitize_planets(struct planet *a, struct planet *b, const double time);
 struct planet *merge_planets(struct planet *a, struct planet *b);
-void move_planet(struct planet *p, const double time);
+struct planet *move_planet(struct planet *p, const double time);
 void print_planet(const struct planet *p);
 
+int planet_spatial_compare(struct quadtree *a, struct quadtree *b);
 #endif