-
Notifications
You must be signed in to change notification settings - Fork 3
Heightmap.h
#include "common/heightmap.h"
il_Common_Heightmap_Quad* il_Common_Heightmap_Quad_new(float heights[4], int depth);
il_Common_Heightmap * il_Common_Heightmap_new(float points[4]);
void il_Common_Heightmap_Quad_divide(il_Common_Heightmap_Quad * quad, size_t numPoints, const float * points);
const il_Common_String il_Common_Heightmap_Quad_tostring(const il_Common_Heightmap_Quad * quad);
This file defines a quadtree heightmap for use in the Graphics and Physics modules. It's a WIP, expect it to be further abstracted in the future.
Quads are nodes of the quadtree, and the heightmap is a container which holds the root node and some other data.
The new functions will assemble a new type corresponding to their name, returning a valid pointer to the initialised struct. The depth attribute is used for setting how deep this node is within the quadtree structure.
The divide function takes a quad node, and a variable number of points, and interpolates the points to construct 4 quad nodes to use as children for the provided quad. These are the valid number of points you can use:
- 0: Interpolated completely from the given quad's points
- 1: The center point is interpolated with the 4 corners of the parent quad
- 4: The 4 points are used as corners
- 5: The first 4 points are used as corners, and the last point is the center
- 9: All of the points are assigned to the children, with no interpolation
The tostring function will convert a valid quad into a string representation.