migrate to new c djstdlib
This commit is contained in:
4
.clangd
4
.clangd
@@ -1,5 +1,7 @@
|
||||
CompileFlags:
|
||||
Add:
|
||||
Add:
|
||||
- -std=c99
|
||||
- -xc
|
||||
# LINUX FLAGS
|
||||
- -DOS_LINUX
|
||||
# WINDOW FLAGS
|
||||
|
||||
@@ -16,7 +16,7 @@ float roundedRectSDF(vec2 sample_pos, vec2 rect_center, vec2 rect_half_size, flo
|
||||
|
||||
void main() {
|
||||
vec2 softness_padding = vec2(
|
||||
max(0, frag_softness*2-1),
|
||||
max(0, frag_softness*2-1),
|
||||
max(0, frag_softness*2-1));
|
||||
|
||||
float border_factor = 1.0f;
|
||||
|
||||
2
build
2
build
@@ -1,6 +1,6 @@
|
||||
#!/bin/bash
|
||||
|
||||
LIB_INCLUDE="-lglfw -lGL -lm"
|
||||
g++ -g -g3 -DOS_LINUX=1 -DENABLE_ASSERT=1 ./src/main.cpp -o ./target/somaesque $LIB_INCLUDE
|
||||
g++ -g -g3 -DOS_LINUX=1 -DENABLE_ASSERT=1 -xc -std=c99 ./src/main.cpp -o ./target/somaesque $LIB_INCLUDE
|
||||
./target/somaesque
|
||||
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
#include <cstring>
|
||||
#include "string.h"
|
||||
#include "VoxelSpace.h"
|
||||
#include "SomaSolve.h"
|
||||
#include "math.h"
|
||||
|
||||
/*
|
||||
void get_dims_input(int dims[3]) {
|
||||
@@ -62,12 +64,12 @@ std::vector<uint64> get_reprs_input(int units_required) {
|
||||
}
|
||||
*/
|
||||
|
||||
typedef list<uint64> SomaSolution;
|
||||
DefineList(size_t, Offset);
|
||||
|
||||
typedef struct Solver {
|
||||
list<uint64>* input;
|
||||
list<size_t>* offsets;
|
||||
list<SomaSolution>* solutions;
|
||||
VoxelSpaceReprList *input;
|
||||
OffsetList *offsets;
|
||||
SomaSolutionList *solutions;
|
||||
} Solver;
|
||||
|
||||
uint64 STD_SOMA[] = { 23ul, 30ul, 15ul, 1043ul, 24594ul, 12306ul, 11ul };
|
||||
@@ -122,25 +124,25 @@ void backtrack_solve_iter(std::vector<uint64> *polycube_input, std::vector<int>
|
||||
}
|
||||
*/
|
||||
|
||||
void backtrackSolve(Arena *arena, Solver *solver, uint64 working_solution = 0, size_t curr_piece = 0) {
|
||||
list<uint64> *input = solver->input;
|
||||
list<size_t> *offsets = solver->offsets;
|
||||
list<SomaSolution> *solutions = solver->solutions;
|
||||
void backtrackSolve(Arena *arena, Solver *solver, uint64 working_solution, size_t curr_piece) {
|
||||
VoxelSpaceReprList *input = solver->input;
|
||||
OffsetList *offsets = solver->offsets;
|
||||
SomaSolutionList *solutions = solver->solutions;
|
||||
size_t start = offsets->data[curr_piece];
|
||||
size_t end = offsets->data[curr_piece + 1];
|
||||
size_t num_pieces = offsets->head - 1;
|
||||
size_t num_pieces = offsets->length - 1;
|
||||
for (size_t i = start; i < end; i++) {
|
||||
bool successful_fuse = !collides(working_solution, input->data[i]);
|
||||
if (successful_fuse) {
|
||||
uint64 new_working_solution = working_solution | input->data[i];
|
||||
solutions->data[solutions->head - 1].data[curr_piece] = input->data[i];
|
||||
solutions->data[solutions->length - 1].data[curr_piece] = input->data[i];
|
||||
if (curr_piece == num_pieces - 1) {
|
||||
list<uint64> last_soln = solutions->data[solutions->head - 1];
|
||||
list<uint64> last_soln_copy = PushList(arena, uint64, last_soln.head);
|
||||
last_soln_copy.length = last_soln.head;
|
||||
last_soln_copy.head = last_soln.head;
|
||||
memcpy(last_soln_copy.data, last_soln.data, last_soln.head * sizeof(uint64));
|
||||
appendList(solutions, last_soln_copy);
|
||||
VoxelSpaceReprList last_soln = solutions->data[solutions->length - 1];
|
||||
VoxelSpaceReprList last_soln_copy = PushList(arena, VoxelSpaceReprList, last_soln.length);
|
||||
last_soln_copy.capacity = last_soln.length;
|
||||
last_soln_copy.length = last_soln.length;
|
||||
memcpy(last_soln_copy.data, last_soln.data, last_soln.length * sizeof(uint64));
|
||||
AppendList(solutions, last_soln_copy);
|
||||
return;
|
||||
} else {
|
||||
backtrackSolve(arena, solver, new_working_solution, curr_piece + 1);
|
||||
@@ -148,40 +150,40 @@ void backtrackSolve(Arena *arena, Solver *solver, uint64 working_solution = 0, s
|
||||
}
|
||||
}
|
||||
if (curr_piece == 0) {
|
||||
solutions->head -= 1;
|
||||
solutions->length -= 1;
|
||||
}
|
||||
}
|
||||
|
||||
list<SomaSolution> getSolutionRotations(Arena *arena, SomaSolution *solution, int dims[3]) {
|
||||
list<SomaSolution> result = PushFullList(arena, SomaSolution, NUM_ROTS_3D);
|
||||
SomaSolutionList getSolutionRotations(Arena *arena, SomaSolution *solution, int dims[3]) {
|
||||
SomaSolutionList result = PushFullList(arena, SomaSolutionList, NUM_ROTS_3D);
|
||||
for (EachIn(result, i)) {
|
||||
result.data[i] = PushList(arena, uint64, solution->head);
|
||||
result.data[i] = PushList(arena, SomaSolution, solution->length);
|
||||
}
|
||||
for (int piece_i = 0; piece_i < solution->head; piece_i++) {
|
||||
for (int piece_i = 0; piece_i < solution->length; piece_i++) {
|
||||
Space space = {
|
||||
solution->data[piece_i],
|
||||
dims[0],
|
||||
dims[1],
|
||||
dims[2],
|
||||
};
|
||||
list<Space> pieceRotations = getAllRotations(arena, &space);
|
||||
for (int rot_i = 0; rot_i < pieceRotations.head; rot_i++) {
|
||||
appendList(&result.data[rot_i], pieceRotations.data[rot_i].space);
|
||||
VoxelSpaceList pieceRotations = getAllRotations(arena, &space);
|
||||
for (int rot_i = 0; rot_i < pieceRotations.length; rot_i++) {
|
||||
AppendList(&result.data[rot_i], pieceRotations.data[rot_i].space);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
list<SomaSolution> filterUnique(Arena *arena, list<SomaSolution> *solutions, int dims[3]) {
|
||||
if (solutions->head == 0) {
|
||||
return list<SomaSolution>{NULL,0,0};
|
||||
SomaSolutionList filterUnique(Arena *arena, SomaSolutionList *solutions, int dims[3]) {
|
||||
if (solutions->length == 0) {
|
||||
return (SomaSolutionList)EmptyList();
|
||||
}
|
||||
list<SomaSolution> uniqueSolns = PushList(arena, SomaSolution, solutions->head);
|
||||
SomaSolutionList uniqueSolns = PushList(arena, SomaSolutionList, solutions->length);
|
||||
for (EachIn(*solutions, i)) {
|
||||
SomaSolution solution = solutions->data[i];
|
||||
bool foundMatch = false;
|
||||
Scratch temp = scratchStart(&arena, 1);
|
||||
list<SomaSolution> rots = getSolutionRotations(temp.arena, &solution, dims);
|
||||
SomaSolutionList rots = getSolutionRotations(temp.arena, &solution, dims);
|
||||
for (EachIn(rots, j)) {
|
||||
SomaSolution rotation = rots.data[j];
|
||||
for (EachIn(uniqueSolns, k)) {
|
||||
@@ -204,11 +206,11 @@ list<SomaSolution> filterUnique(Arena *arena, list<SomaSolution> *solutions, int
|
||||
}
|
||||
scratchEnd(temp);
|
||||
if (!foundMatch) {
|
||||
SomaSolution solutionCopy = PushList(arena, uint64, solution.head);
|
||||
solutionCopy.length = solution.head;
|
||||
solutionCopy.head = solution.head;
|
||||
memcpy(solutionCopy.data, solution.data, solution.head * sizeof(uint64));
|
||||
appendList(&uniqueSolns, solutionCopy);
|
||||
SomaSolution solutionCopy = PushList(arena, SomaSolution, solution.length);
|
||||
solutionCopy.capacity = solution.length;
|
||||
solutionCopy.length = solution.length;
|
||||
memcpy(solutionCopy.data, solution.data, solution.length * sizeof(SomaSolutionList_underlying));
|
||||
AppendList(&uniqueSolns, solutionCopy);
|
||||
}
|
||||
}
|
||||
return uniqueSolns;
|
||||
@@ -222,56 +224,56 @@ uint64 factorial(int n) {
|
||||
return result;
|
||||
}
|
||||
|
||||
list<SomaSolution> solve(uint64 *reprs_in, uint32 reprs_in_count, int dims[3]) {
|
||||
SomaSolutionList solve(uint64 *reprs_in, uint32 reprs_in_count, int dims[3]) {
|
||||
Arena *arena = arenaAlloc(Megabytes(64));
|
||||
Arena *permsArena = arenaAlloc(Megabytes(128));
|
||||
|
||||
list<size_t> offsets = PushList(arena, size_t, reprs_in_count + 1);
|
||||
OffsetList offsets = PushList(arena, OffsetList, reprs_in_count + 1);
|
||||
|
||||
list<uint64> polycubes = PushList(arena, uint64, 0);
|
||||
VoxelSpaceReprList polycubes = PushList(arena, VoxelSpaceReprList, 0);
|
||||
|
||||
Space empty_voxel_space = {
|
||||
{},
|
||||
0,
|
||||
dims[0],
|
||||
dims[1],
|
||||
dims[2],
|
||||
};
|
||||
|
||||
appendList(&offsets, (size_t)0);
|
||||
AppendList(&offsets, 0);
|
||||
|
||||
uint64 possibleCombos = 0;
|
||||
|
||||
{
|
||||
list<uint64> positions = {};
|
||||
VoxelSpaceReprList positions = {};
|
||||
Space space = empty_voxel_space;
|
||||
space.space = reprs_in[0];
|
||||
cullEmptySpace(&space);
|
||||
positions = getAllPositionsInPrism(permsArena, &space, dims);
|
||||
possibleCombos += positions.head;
|
||||
uint64 *insertion = PushArray(arena, uint64, positions.length);
|
||||
possibleCombos += positions.length;
|
||||
VoxelSpaceReprList_underlying *insertion = PushArray(arena, uint64, positions.capacity);
|
||||
polycubes.capacity += positions.capacity;
|
||||
polycubes.length += positions.length;
|
||||
polycubes.head += positions.head;
|
||||
memcpy(insertion, positions.data, positions.length * sizeof(uint64));
|
||||
memcpy(insertion, positions.data, positions.capacity * sizeof(VoxelSpaceReprList_underlying));
|
||||
};
|
||||
|
||||
for (size_t i = 1; i < reprs_in_count; i++) {
|
||||
appendList(&offsets, polycubes.length);
|
||||
AppendList(&offsets, polycubes.capacity);
|
||||
Space space = empty_voxel_space;
|
||||
space.space = reprs_in[i];
|
||||
cullEmptySpace(&space);
|
||||
list<uint64> perms = getAllPermutationsInPrism(permsArena, &space, dims);
|
||||
possibleCombos *= perms.head;
|
||||
uint64 *insertion = PushArray(arena, uint64, perms.length);
|
||||
VoxelSpaceReprList perms = getAllPermutationsInPrism(permsArena, &space, dims);
|
||||
possibleCombos *= perms.length;
|
||||
VoxelSpaceReprList_underlying *insertion = PushArray(arena, uint64, perms.capacity);
|
||||
polycubes.capacity += perms.capacity;
|
||||
polycubes.length += perms.length;
|
||||
polycubes.head += perms.head;
|
||||
memcpy(insertion, perms.data, perms.length * sizeof(uint64));
|
||||
memcpy(insertion, perms.data, perms.capacity * sizeof(VoxelSpaceReprList_underlying));
|
||||
}
|
||||
|
||||
appendList(&offsets, polycubes.head);
|
||||
AppendList(&offsets, polycubes.length);
|
||||
|
||||
list<SomaSolution> solutions = PushList(permsArena, SomaSolution, (size_t)floor(sqrt(possibleCombos)));
|
||||
SomaSolution initialSoln = PushFullList(permsArena, uint64, reprs_in_count);
|
||||
appendList(&solutions, initialSoln);
|
||||
SomaSolutionList solutions = PushList(permsArena, SomaSolutionList, (size_t)floor(sqrt(possibleCombos)));
|
||||
SomaSolution initialSoln = PushFullList(permsArena, SomaSolution, reprs_in_count);
|
||||
AppendList(&solutions, initialSoln);
|
||||
|
||||
Solver solver = {
|
||||
&polycubes,
|
||||
@@ -279,7 +281,7 @@ list<SomaSolution> solve(uint64 *reprs_in, uint32 reprs_in_count, int dims[3]) {
|
||||
&solutions,
|
||||
};
|
||||
|
||||
backtrackSolve(permsArena, &solver);
|
||||
backtrackSolve(permsArena, &solver, 0, 0);
|
||||
|
||||
return filterUnique(permsArena, solver.solutions, dims);
|
||||
}
|
||||
@@ -291,6 +293,6 @@ void interactive_cmd_line_solve_soma() {
|
||||
//std::cout << '\n';
|
||||
//std::vector<uint64> reprs = get_reprs_input(dims[0]*dims[1]*dims[2]);
|
||||
print("Great. Calculating solutions...\n");
|
||||
list<SomaSolution> solutions = solve(STD_SOMA, ArrayCount(STD_SOMA), dims);
|
||||
print("%zu solutions found.\n", solutions.head);
|
||||
SomaSolutionList solutions = solve(STD_SOMA, ArrayCount(STD_SOMA), dims);
|
||||
print("%zu solutions found.\n", solutions.length);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
#include "VoxelSpace.h"
|
||||
#include "lib/djstdlib/core.h"
|
||||
|
||||
extern uint64 STD_SOMA[];
|
||||
typedef list<uint64> SomaSolution;
|
||||
list<SomaSolution> solve(list<uint64> *reprs_in, int dims[3]);
|
||||
typedef VoxelSpaceReprList SomaSolution;
|
||||
DefineList(SomaSolution, SomaSolution);
|
||||
|
||||
SomaSolutionList solve(uint64 *reprs_in, uint32 reprs_in_length, int dims[3]);
|
||||
void interactive_cmd_line_solve_soma();
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
#include <cstring>
|
||||
#include "string.h"
|
||||
#include "VoxelSpace.h"
|
||||
|
||||
int index(int dim_y, int dim_z, int x, int y, int z) {
|
||||
return dim_y * dim_z * x + dim_z * y + z;
|
||||
}
|
||||
|
||||
// ┌ ┐ ┌ ┐ ┌ ┐
|
||||
// ┌ ┐ ┌ ┐ ┌ ┐
|
||||
// │ 1, 0, 0 │ │ x │ │ x │
|
||||
// │ 0, 0, -1 │ * │ y │ = │-z │
|
||||
// │ 0, 1, 0 │ │ z │ │ y │
|
||||
@@ -14,7 +14,7 @@ int newIndexRotX(Space *space, int x, int y, int z) {
|
||||
return space->dim_z * space->dim_y * x + space->dim_y * (space->dim_z - 1 - z) + y;
|
||||
}
|
||||
|
||||
// ┌ ┐ ┌ ┐ ┌ ┐
|
||||
// ┌ ┐ ┌ ┐ ┌ ┐
|
||||
// │ 0, 0, 1 │ │ x │ │ z │
|
||||
// │ 0, 1, 0 │ * │ y │ = │-y │
|
||||
// │ -1, 0, 0 │ │ z │ │ x │
|
||||
@@ -23,7 +23,7 @@ int newIndexRotY(Space *space, int x, int y, int z) {
|
||||
return space->dim_y * space->dim_x * z + space->dim_x * y + (space->dim_x - 1 - x);
|
||||
}
|
||||
|
||||
// ┌ ┐ ┌ ┐ ┌ ┐
|
||||
// ┌ ┐ ┌ ┐ ┌ ┐
|
||||
// │ 0, -1, 0 │ │ x │ │-y │
|
||||
// │ 1, 0, 0 │ * │ y │ = │ x │
|
||||
// │ 0, 0, 1 │ │ z │ │ z │
|
||||
@@ -32,7 +32,7 @@ int newIndexRotZ(Space *space, int x, int y, int z) {
|
||||
return space->dim_x * space->dim_z * (space->dim_y - 1 - y) + space->dim_z * x + z;
|
||||
}
|
||||
|
||||
uint64 toggle(uint64 space, int index) {
|
||||
inline uint64 toggle(uint64 space, int index) {
|
||||
space ^= 1ull << index;
|
||||
return space;
|
||||
}
|
||||
@@ -46,13 +46,15 @@ uint64 set(uint64 space, int index, bool val) {
|
||||
return space;
|
||||
}
|
||||
|
||||
bool collides(uint64 a, uint64 b) {
|
||||
inline bool collides(uint64 a, uint64 b) {
|
||||
return (a | b) != (a ^ b);
|
||||
}
|
||||
|
||||
/*
|
||||
bool collides(Space *a, Space *b) {
|
||||
return (a->space | b->space) != (a->space ^ b->space);
|
||||
}
|
||||
*/
|
||||
|
||||
bool filledAt(Space *space, int x, int y, int z) {
|
||||
uint64 mask = 1ull << (space->dim_y * space->dim_z * x + space->dim_z * y + z);
|
||||
@@ -165,7 +167,7 @@ bool isMatch(Space *a, Space *b) {
|
||||
&& a->dim_z == b->dim_z;
|
||||
}
|
||||
|
||||
void pushNewUniqueSpins(list<Space> *existingSpaces, Space* spaceToSpin) {
|
||||
void pushNewUniqueSpins(VoxelSpaceList *existingSpaces, Space* spaceToSpin) {
|
||||
Space spins[4] = {};
|
||||
spins[0] = *spaceToSpin;
|
||||
for (int i = 0; i < 3; i++) {
|
||||
@@ -181,21 +183,21 @@ void pushNewUniqueSpins(list<Space> *existingSpaces, Space* spaceToSpin) {
|
||||
}
|
||||
}
|
||||
if (!matchFound) {
|
||||
appendList(existingSpaces, spins[i]);
|
||||
AppendList(existingSpaces, spins[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void pushXAxisSpins(Arena *arena, list<Space> *existingSpaces, Space* spaceToSpin) {
|
||||
void pushXAxisSpins(Arena *arena, VoxelSpaceList *existingSpaces, Space* spaceToSpin) {
|
||||
Space refSpace = *spaceToSpin;
|
||||
for (int i = 0; i < 4; i++) {
|
||||
rotate90X(&refSpace);
|
||||
appendList(existingSpaces, refSpace);
|
||||
AppendList(existingSpaces, refSpace);
|
||||
}
|
||||
}
|
||||
|
||||
list<Space> getUniqueRotations(Arena *arena, Space *space) {
|
||||
list<Space> rotations = PushList(arena, Space, 24);
|
||||
VoxelSpaceList getUniqueRotations(Arena *arena, Space *space) {
|
||||
VoxelSpaceList rotations = PushList(arena, VoxelSpaceList, 24);
|
||||
Space refSpace = *space;
|
||||
cullEmptySpace(&refSpace);
|
||||
pushNewUniqueSpins(&rotations, &refSpace);
|
||||
@@ -210,13 +212,13 @@ list<Space> getUniqueRotations(Arena *arena, Space *space) {
|
||||
rotate90Z(&refSpace);
|
||||
rotate90Z(&refSpace);
|
||||
pushNewUniqueSpins(&rotations, &refSpace);
|
||||
rotations.length = rotations.head;
|
||||
arenaPopTo(arena, rotations.data + rotations.head);
|
||||
rotations.capacity = rotations.length;
|
||||
arenaPopTo(arena, rotations.data + rotations.length);
|
||||
return rotations;
|
||||
}
|
||||
|
||||
list<Space> getAllRotations(Arena *arena, Space *space) {
|
||||
list<Space> rotations = PushList(arena, Space, 24);
|
||||
VoxelSpaceList getAllRotations(Arena *arena, Space *space) {
|
||||
VoxelSpaceList rotations = PushList(arena, VoxelSpaceList, 24);
|
||||
Space refSpace = *space;
|
||||
pushXAxisSpins(arena, &rotations, &refSpace);
|
||||
rotate90Y(&refSpace);
|
||||
@@ -233,9 +235,9 @@ list<Space> getAllRotations(Arena *arena, Space *space) {
|
||||
return rotations;
|
||||
}
|
||||
|
||||
list<uint64> getAllPositionsInPrism(Arena *arena, Space *space, int prism_dims[3]) {
|
||||
VoxelSpaceReprList getAllPositionsInPrism(Arena *arena, Space *space, int prism_dims[3]) {
|
||||
if (space->dim_x > prism_dims[0] || space->dim_y > prism_dims[1] || space->dim_z > prism_dims[2]) {
|
||||
return list<uint64>{0};
|
||||
return (VoxelSpaceReprList)EmptyList();
|
||||
}
|
||||
int count = 0;
|
||||
void *startList = 0;
|
||||
@@ -263,24 +265,24 @@ list<uint64> getAllPositionsInPrism(Arena *arena, Space *space, int prism_dims[3
|
||||
}
|
||||
}
|
||||
}
|
||||
list<uint64> result = {};
|
||||
VoxelSpaceReprList result = {};
|
||||
result.data = (uint64 *)startList;
|
||||
result.capacity = count;
|
||||
result.length = count;
|
||||
result.head = count;
|
||||
return result;
|
||||
}
|
||||
|
||||
list<uint64> getAllPermutationsInPrism(Arena *arena, Space *space, int prism_dims[3]) {
|
||||
VoxelSpaceReprList getAllPermutationsInPrism(Arena *arena, Space *space, int prism_dims[3]) {
|
||||
Scratch temp = scratchStart(&arena, 1);
|
||||
|
||||
list<Space> rotations = getUniqueRotations(temp.arena, space);
|
||||
list<uint64> result = PushList(arena, uint64, 0);
|
||||
VoxelSpaceList rotations = getUniqueRotations(temp.arena, space);
|
||||
VoxelSpaceReprList result = PushList(arena, VoxelSpaceReprList, 0);
|
||||
for (EachIn(rotations, i)) {
|
||||
list<uint64> positions = getAllPositionsInPrism(temp.arena, &rotations.data[i], prism_dims);
|
||||
uint64 *listAppend = PushArray(arena, uint64, positions.length);
|
||||
memcpy(listAppend, positions.data, positions.length * sizeof(uint64));
|
||||
VoxelSpaceReprList positions = getAllPositionsInPrism(temp.arena, &rotations.data[i], prism_dims);
|
||||
uint64 *listAppend = PushArray(arena, uint64, positions.capacity);
|
||||
memcpy(listAppend, positions.data, positions.capacity * sizeof(uint64));
|
||||
result.capacity += positions.capacity;
|
||||
result.length += positions.length;
|
||||
result.head += positions.head;
|
||||
}
|
||||
|
||||
scratchEnd(temp);
|
||||
|
||||
@@ -3,23 +3,26 @@
|
||||
|
||||
#include "lib/djstdlib/core.h"
|
||||
|
||||
constexpr int NUM_ROTS_3D = 24;
|
||||
#define NUM_ROTS_3D 24
|
||||
|
||||
struct Extrema {
|
||||
typedef struct Extrema {
|
||||
int xMax;
|
||||
int xMin;
|
||||
int yMax;
|
||||
int yMin;
|
||||
int zMax;
|
||||
int zMin;
|
||||
};
|
||||
} Extrema;
|
||||
|
||||
struct Space {
|
||||
typedef struct Space {
|
||||
uint64 space;
|
||||
int dim_x;
|
||||
int dim_y;
|
||||
int dim_z;
|
||||
};
|
||||
} Space;
|
||||
|
||||
DefineList(Space, VoxelSpace);
|
||||
DefineList(uint64, VoxelSpaceRepr);
|
||||
|
||||
int newIndexRotX(Space *space, int x, int y, int z);
|
||||
|
||||
@@ -31,7 +34,7 @@ uint64 toggle(uint64 space, int index);
|
||||
|
||||
uint64 set(uint64 space, int index, bool val);
|
||||
|
||||
bool collides(Space *a, Space *b);
|
||||
//bool collides(Space *a, Space *b);
|
||||
bool collides(uint64 a, uint64 b);
|
||||
|
||||
Space add(Space *a, Space *b);
|
||||
@@ -50,15 +53,15 @@ void rotate90Y(Space *space);
|
||||
|
||||
void rotate90Z(Space *space);
|
||||
|
||||
void pushNewUniqueSpins(list<Space> *existingSpaces, Space* spaceToSpin);
|
||||
void pushNewUniqueSpins(VoxelSpaceList *existingSpaces, Space* spaceToSpin);
|
||||
|
||||
list<Space> getUniqueRotations(Arena *arena, Space *space);
|
||||
VoxelSpaceList getUniqueRotations(Arena *arena, Space *space);
|
||||
|
||||
list<Space> getAllRotations(Arena *arena, Space *space);
|
||||
VoxelSpaceList getAllRotations(Arena *arena, Space *space);
|
||||
|
||||
list<uint64> getAllPositionsInPrism(Arena *arena, Space *space, int prism_dims[3]);
|
||||
VoxelSpaceReprList getAllPositionsInPrism(Arena *arena, Space *space, int prism_dims[3]);
|
||||
|
||||
list<uint64> getAllPermutationsInPrism(Arena *arena, Space *space, int prism_dims[3]);
|
||||
VoxelSpaceReprList getAllPermutationsInPrism(Arena *arena, Space *space, int prism_dims[3]);
|
||||
|
||||
int size(uint64 space);
|
||||
|
||||
@@ -68,4 +71,4 @@ void spaceToggle(Space *space, int x, int y, int z);
|
||||
|
||||
void spaceSet(Space *space, bool val, int x, int y, int z);
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -13,7 +13,7 @@ real32 hueToRGB(real32 p, real32 q, real32 t) {
|
||||
return p;
|
||||
};
|
||||
|
||||
Vector4<real32> hslToHex(real32 h, real32 s, real32 l) {
|
||||
RLVector4 hslToHex(real32 h, real32 s, real32 l) {
|
||||
h /= 360;
|
||||
s /= 100;
|
||||
l /= 100;
|
||||
@@ -27,10 +27,10 @@ Vector4<real32> hslToHex(real32 h, real32 s, real32 l) {
|
||||
g = hueToRGB(p, q, h);
|
||||
b = hueToRGB(p, q, h - 1.0f / 3);
|
||||
}
|
||||
return vec4<real32>(r, g, b, 1);
|
||||
return (RLVector4){r, g, b, 1};
|
||||
}
|
||||
|
||||
Vector4<real32> colorFromIndex(int index) {
|
||||
RLVector4 colorFromIndex(int index) {
|
||||
real32 color_wheel_cycle = floorf(index / 6.0f);
|
||||
real32 darkness_cycle = floorf(index / 12.0f);
|
||||
real32 spacing = (360.0f / 6.0f);
|
||||
|
||||
@@ -2,16 +2,17 @@
|
||||
#define COLOR_H
|
||||
|
||||
#include "../lib/djstdlib/core.h"
|
||||
#include "../lib/raymath.h"
|
||||
|
||||
#define COLOR_BLACK vec4<real32>(0, 0, 0, 1)
|
||||
#define COLOR_RED vec4<real32>(1, 0, 0, 1)
|
||||
#define COLOR_GREEN vec4<real32>(0, 1, 0, 1)
|
||||
#define COLOR_BLUE vec4<real32>(0, 0, 1, 1)
|
||||
#define COLOR_MAGENTA vec4<real32>(1, 0, 1, 1)
|
||||
#define COLOR_YELLOW vec4<real32>(1, 1, 0, 1)
|
||||
#define COLOR_CYAN vec4<real32>(0, 1, 1, 1)
|
||||
#define COLOR_WHITE vec4<real32>(1, 1, 1, 1)
|
||||
#define COLOR_BLACK (RLVector4){0, 0, 0, 1}
|
||||
#define COLOR_RED (RLVector4){1, 0, 0, 1}
|
||||
#define COLOR_GREEN (RLVector4){0, 1, 0, 1}
|
||||
#define COLOR_BLUE (RLVector4){0, 0, 1, 1}
|
||||
#define COLOR_MAGENTA (RLVector4){1, 0, 1, 1}
|
||||
#define COLOR_YELLOW (RLVector4){1, 1, 0, 1}
|
||||
#define COLOR_CYAN (RLVector4){0, 1, 1, 1}
|
||||
#define COLOR_WHITE (RLVector4){1, 1, 1, 1}
|
||||
|
||||
Vector4<real32> colorFromIndex(int index);
|
||||
RLVector4 colorFromIndex(int index);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -3,11 +3,14 @@
|
||||
#include "../lib/djstdlib/os.h"
|
||||
|
||||
static void tinyobj_get_filedata(void* ctx, const char* filename, const int is_mtl, const char* obj_filename, char** data, size_t* len) {
|
||||
string file = os_readEntireFile((Arena *)ctx, "./assets/models/cube.obj"_s);
|
||||
string file = os_readEntireFile((Arena *)ctx, s("./assets/models/cube.obj"));
|
||||
*data = file.str;
|
||||
*len = file.length;
|
||||
}
|
||||
|
||||
DefineList(uint32, MeshIndex);
|
||||
DefineList(real32, MeshValue);
|
||||
|
||||
Mesh createMesh(const char* obj_file) {
|
||||
Scratch temp = scratchStart(0, 0);
|
||||
|
||||
@@ -36,10 +39,10 @@ Mesh createMesh(const char* obj_file) {
|
||||
return result;
|
||||
}
|
||||
|
||||
list<uint32> indices = PushFullList(temp.arena, uint32, attrib.num_faces);
|
||||
list<real32> vertices = PushFullList(temp.arena, real32, 3*attrib.num_faces);
|
||||
list<real32> normals = PushFullList(temp.arena, real32, 3*attrib.num_faces);
|
||||
list<real32> texcoords = PushFullList(temp.arena, real32, 2*attrib.num_faces);
|
||||
MeshIndexList indices = PushFullList(temp.arena, MeshIndexList, attrib.num_faces);
|
||||
MeshValueList vertices = PushFullList(temp.arena, MeshValueList, 3*attrib.num_faces);
|
||||
MeshValueList normals = PushFullList(temp.arena, MeshValueList, 3*attrib.num_faces);
|
||||
MeshValueList texcoords = PushFullList(temp.arena, MeshValueList, 2*attrib.num_faces);
|
||||
|
||||
for (int i = 0; i < attrib.num_faces; i++) {
|
||||
tinyobj_vertex_index_t vertex_data = attrib.faces[i];
|
||||
@@ -86,7 +89,7 @@ Mesh createMesh(const char* obj_file) {
|
||||
return result;
|
||||
}
|
||||
|
||||
Mesh createMesh(const Shape* shape) {
|
||||
Mesh createMeshFromShape(const Shape* shape) {
|
||||
Mesh result = {0};
|
||||
|
||||
result.num_indices = shape->indices_size;
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
#include "../lib/djstdlib/core.h"
|
||||
#include "geometry.h"
|
||||
|
||||
struct Mesh {
|
||||
typedef struct {
|
||||
uint32 vao;
|
||||
union {
|
||||
struct {
|
||||
@@ -17,9 +17,9 @@ struct Mesh {
|
||||
uint32 vbos[4];
|
||||
};
|
||||
uint64 num_indices;
|
||||
};
|
||||
} Mesh;
|
||||
|
||||
Mesh createMesh(const char* obj_file);
|
||||
Mesh createMesh(const Shape* shape);
|
||||
Mesh createMeshFromShape(const Shape* shape);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -4,10 +4,10 @@
|
||||
#include "../lib/glad/glad.h"
|
||||
#include "../lib/raymath.h"
|
||||
|
||||
enum ShaderType {
|
||||
fragment=GL_FRAGMENT_SHADER,
|
||||
vertex=GL_VERTEX_SHADER,
|
||||
};
|
||||
typedef enum {
|
||||
ShaderType_fragment=GL_FRAGMENT_SHADER,
|
||||
ShaderType_vertex=GL_VERTEX_SHADER,
|
||||
} ShaderType;
|
||||
|
||||
uint32 createGlShader(string file_path, ShaderType shader_type) {
|
||||
Scratch temp = scratchStart(0, 0);
|
||||
@@ -23,7 +23,7 @@ uint32 createGlShader(string file_path, ShaderType shader_type) {
|
||||
glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &info_log_length);
|
||||
string info_log = PushString(temp.arena, (size_t)info_log_length + 1);
|
||||
glGetShaderInfoLog(shader, info_log_length, NULL, info_log.str);
|
||||
const char* shader_type_name = shader_type == ShaderType::fragment ? "FRAGMENT" : "VERTEX";
|
||||
const char* shader_type_name = shader_type == ShaderType_fragment ? "FRAGMENT" : "VERTEX";
|
||||
print("%s shader compilation error (%S):\n%S", shader_type_name, file_path, info_log);
|
||||
}
|
||||
scratchEnd(temp);
|
||||
@@ -35,8 +35,8 @@ Shader createShader(string vertex_path, string fragment_path) {
|
||||
|
||||
Shader result = {0};
|
||||
|
||||
uint32 vertex_shader = createGlShader(vertex_path, ShaderType::vertex);
|
||||
uint32 fragment_shader = createGlShader(fragment_path, ShaderType::fragment);
|
||||
uint32 vertex_shader = createGlShader(vertex_path, ShaderType_vertex);
|
||||
uint32 fragment_shader = createGlShader(fragment_path, ShaderType_fragment);
|
||||
|
||||
result.progId = glCreateProgram();
|
||||
glAttachShader(result.progId, vertex_shader);
|
||||
@@ -65,37 +65,28 @@ void setUniformMat4fv(Shader *s, const char *uniformName, Matrix *matrix) {
|
||||
glGetUniformLocation(s->progId, uniformName),
|
||||
1, GL_FALSE, MatrixToFloat(*matrix));
|
||||
}
|
||||
void setUniformMat4fv(int uniformLocation, Matrix *matrix) {
|
||||
void setUniformMat4fvByLoc(int uniformLocation, Matrix *matrix) {
|
||||
glUniformMatrix4fv(uniformLocation, 1, GL_FALSE, MatrixToFloat(*matrix));
|
||||
}
|
||||
|
||||
void setUniform4fv(Shader *s, const char *uniformName, Vector4<real32> *vector) {
|
||||
glUniform4fv(glGetUniformLocation(s->progId, uniformName), 1, vector->vec);
|
||||
}
|
||||
void setUniform4fv(Shader *s, const char *uniformName, RLVector4 *vector) {
|
||||
glUniform4fv(glGetUniformLocation(s->progId, uniformName), 1, (const GLfloat *)vector);
|
||||
}
|
||||
void setUniform4fv(int uniformLocation, RLVector4 *vector) {
|
||||
void setUniform4fvByLoc(int uniformLocation, RLVector4 *vector) {
|
||||
glUniform4fv(uniformLocation, 1, (const GLfloat *)vector);
|
||||
}
|
||||
|
||||
void setUniform3fv(Shader *s, const char *uniformName, Vector3<real32> *vector) {
|
||||
glUniform3fv(glGetUniformLocation(s->progId, uniformName), 1, vector->vec);
|
||||
}
|
||||
void setUniform3fv(Shader *s, const char *uniformName, RLVector3 *vector) {
|
||||
glUniform3fv(glGetUniformLocation(s->progId, uniformName), 1, Vector3ToFloat(*vector));
|
||||
}
|
||||
void setUniform3fv(int uniformLocation, RLVector3 *vector) {
|
||||
void setUniform3fvByLoc(int uniformLocation, RLVector3 *vector) {
|
||||
glUniform3fv(uniformLocation, 1, Vector3ToFloat(*vector));
|
||||
}
|
||||
|
||||
void setUniform2fv(Shader *s, const char *uniformName, Vector2<real32> *vector) {
|
||||
glUniform2fv(glGetUniformLocation(s->progId, uniformName), 1, vector->vec);
|
||||
}
|
||||
void setUniform2fv(Shader *s, const char *uniformName, RLVector2 *vector) {
|
||||
glUniform2fv(glGetUniformLocation(s->progId, uniformName), 1, (const GLfloat *)vector);
|
||||
}
|
||||
void setUniform2fv(int uniformLocation, RLVector2 *vector) {
|
||||
void setUniform2fvByLoc(int uniformLocation, RLVector2 *vector) {
|
||||
glUniform2fv(uniformLocation, 1, (const GLfloat *)vector);
|
||||
}
|
||||
|
||||
|
||||
@@ -4,23 +4,23 @@
|
||||
#include "../lib/raymath.h"
|
||||
#include "../lib/djstdlib/core.h"
|
||||
|
||||
struct Shader {
|
||||
typedef struct {
|
||||
uint32 progId;
|
||||
};
|
||||
} Shader;
|
||||
|
||||
Shader createShader(string vertex_path, string fragment_path);
|
||||
|
||||
void setUniformMat4fv(Shader *s, const char *uniformName, Matrix *matrix);
|
||||
void setUniformMat4fv(int uniformLocation, Matrix *matrix);
|
||||
void setUniformMat4fvByLoc(int uniformLocation, Matrix *matrix);
|
||||
|
||||
void setUniform4fv(Shader *s, const char *uniformName, RLVector4 *vector);
|
||||
void setUniform4fv(int uniformLocation, RLVector4 *vector);
|
||||
void setUniform4fvByLoc(int uniformLocation, RLVector4 *vector);
|
||||
|
||||
void setUniform3fv(Shader *s, const char *uniformName, RLVector3 *vector);
|
||||
void setUniform3fv(int uniformLocation, RLVector3 *vector);
|
||||
void setUniform3fvByLoc(int uniformLocation, RLVector3 *vector);
|
||||
|
||||
void setUniform2fv(Shader *s, const char *uniformName, RLVector2 *vector);
|
||||
void setUniform2fv(int uniformLocation, RLVector2 *vector);
|
||||
void setUniform2fvByLoc(int uniformLocation, RLVector2 *vector);
|
||||
|
||||
int getUniformLocation(Shader *s, const char *uniformName);
|
||||
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
#ifndef LEDDA_TEXTURE_H
|
||||
#define LEDDA_TEXTURE_H
|
||||
|
||||
struct Texture {
|
||||
typedef struct {
|
||||
unsigned int tex_id;
|
||||
int width;
|
||||
int height;
|
||||
};
|
||||
} Texture;
|
||||
|
||||
Texture createTexture(const char* source_path);
|
||||
|
||||
|
||||
@@ -3,14 +3,14 @@
|
||||
|
||||
#include "stddef.h"
|
||||
|
||||
struct Shape {
|
||||
typedef struct {
|
||||
unsigned int* indices;
|
||||
size_t indices_size;
|
||||
float* uv;
|
||||
size_t uv_size;
|
||||
float* xyz;
|
||||
size_t xyz_size;
|
||||
};
|
||||
} Shape;
|
||||
|
||||
extern const Shape TRIANGLE;
|
||||
extern const Shape SQUARE;
|
||||
|
||||
Submodule src/lib/djstdlib updated: ea2ddf60f3...27e7d74895
@@ -117,7 +117,7 @@
|
||||
typedef struct RLVector2 {
|
||||
float x;
|
||||
float y;
|
||||
} RMVector2;
|
||||
} RLVector2;
|
||||
#define RL_VECTOR2_TYPE
|
||||
#endif
|
||||
|
||||
@@ -233,55 +233,55 @@ RMAPI int FloatEquals(float x, float y)
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
// Vector with components value 0.0f
|
||||
RMAPI RMVector2 Vector2Zero(void)
|
||||
RMAPI RLVector2 Vector2Zero(void)
|
||||
{
|
||||
RMVector2 result = { 0.0f, 0.0f };
|
||||
RLVector2 result = { 0.0f, 0.0f };
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// Vector with components value 1.0f
|
||||
RMAPI RMVector2 Vector2One(void)
|
||||
RMAPI RLVector2 Vector2One(void)
|
||||
{
|
||||
RMVector2 result = { 1.0f, 1.0f };
|
||||
RLVector2 result = { 1.0f, 1.0f };
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// Add two vectors (v1 + v2)
|
||||
RMAPI RMVector2 Vector2Add(RMVector2 v1, RMVector2 v2)
|
||||
RMAPI RLVector2 Vector2Add(RLVector2 v1, RLVector2 v2)
|
||||
{
|
||||
RMVector2 result = { v1.x + v2.x, v1.y + v2.y };
|
||||
RLVector2 result = { v1.x + v2.x, v1.y + v2.y };
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// Add vector and float value
|
||||
RMAPI RMVector2 Vector2AddValue(RMVector2 v, float add)
|
||||
RMAPI RLVector2 Vector2AddValue(RLVector2 v, float add)
|
||||
{
|
||||
RMVector2 result = { v.x + add, v.y + add };
|
||||
RLVector2 result = { v.x + add, v.y + add };
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// Subtract two vectors (v1 - v2)
|
||||
RMAPI RMVector2 Vector2Subtract(RMVector2 v1, RMVector2 v2)
|
||||
RMAPI RLVector2 Vector2Subtract(RLVector2 v1, RLVector2 v2)
|
||||
{
|
||||
RMVector2 result = { v1.x - v2.x, v1.y - v2.y };
|
||||
RLVector2 result = { v1.x - v2.x, v1.y - v2.y };
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// Subtract vector by float value
|
||||
RMAPI RMVector2 Vector2SubtractValue(RMVector2 v, float sub)
|
||||
RMAPI RLVector2 Vector2SubtractValue(RLVector2 v, float sub)
|
||||
{
|
||||
RMVector2 result = { v.x - sub, v.y - sub };
|
||||
RLVector2 result = { v.x - sub, v.y - sub };
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// Calculate vector length
|
||||
RMAPI float Vector2Length(RMVector2 v)
|
||||
RMAPI float Vector2Length(RLVector2 v)
|
||||
{
|
||||
float result = sqrtf((v.x*v.x) + (v.y*v.y));
|
||||
|
||||
@@ -289,7 +289,7 @@ RMAPI float Vector2Length(RMVector2 v)
|
||||
}
|
||||
|
||||
// Calculate vector square length
|
||||
RMAPI float Vector2LengthSqr(RMVector2 v)
|
||||
RMAPI float Vector2LengthSqr(RLVector2 v)
|
||||
{
|
||||
float result = (v.x*v.x) + (v.y*v.y);
|
||||
|
||||
@@ -297,7 +297,7 @@ RMAPI float Vector2LengthSqr(RMVector2 v)
|
||||
}
|
||||
|
||||
// Calculate two vectors dot product
|
||||
RMAPI float Vector2DotProduct(RMVector2 v1, RMVector2 v2)
|
||||
RMAPI float Vector2DotProduct(RLVector2 v1, RLVector2 v2)
|
||||
{
|
||||
float result = (v1.x*v2.x + v1.y*v2.y);
|
||||
|
||||
@@ -305,7 +305,7 @@ RMAPI float Vector2DotProduct(RMVector2 v1, RMVector2 v2)
|
||||
}
|
||||
|
||||
// Calculate two vectors cross product
|
||||
RMAPI float Vector2CrossProduct(RMVector2 v1, RMVector2 v2)
|
||||
RMAPI float Vector2CrossProduct(RLVector2 v1, RLVector2 v2)
|
||||
{
|
||||
float result = (v1.x*v2.y - v1.y*v2.x);
|
||||
|
||||
@@ -313,7 +313,7 @@ RMAPI float Vector2CrossProduct(RMVector2 v1, RMVector2 v2)
|
||||
}
|
||||
|
||||
// Calculate distance between two vectors
|
||||
RMAPI float Vector2Distance(RMVector2 v1, RMVector2 v2)
|
||||
RMAPI float Vector2Distance(RLVector2 v1, RLVector2 v2)
|
||||
{
|
||||
float result = sqrtf((v1.x - v2.x)*(v1.x - v2.x) + (v1.y - v2.y)*(v1.y - v2.y));
|
||||
|
||||
@@ -321,7 +321,7 @@ RMAPI float Vector2Distance(RMVector2 v1, RMVector2 v2)
|
||||
}
|
||||
|
||||
// Calculate square distance between two vectors
|
||||
RMAPI float Vector2DistanceSqr(RMVector2 v1, RMVector2 v2)
|
||||
RMAPI float Vector2DistanceSqr(RLVector2 v1, RLVector2 v2)
|
||||
{
|
||||
float result = ((v1.x - v2.x)*(v1.x - v2.x) + (v1.y - v2.y)*(v1.y - v2.y));
|
||||
|
||||
@@ -331,7 +331,7 @@ RMAPI float Vector2DistanceSqr(RMVector2 v1, RMVector2 v2)
|
||||
// Calculate the signed angle from v1 to v2, relative to the origin (0, 0)
|
||||
// NOTE: Coordinate system convention: positive X right, positive Y down
|
||||
// positive angles appear clockwise, and negative angles appear counterclockwise
|
||||
RMAPI float Vector2Angle(RMVector2 v1, RMVector2 v2)
|
||||
RMAPI float Vector2Angle(RLVector2 v1, RLVector2 v2)
|
||||
{
|
||||
float result = 0.0f;
|
||||
|
||||
@@ -346,7 +346,7 @@ RMAPI float Vector2Angle(RMVector2 v1, RMVector2 v2)
|
||||
// Calculate angle defined by a two vectors line
|
||||
// NOTE: Parameters need to be normalized
|
||||
// Current implementation should be aligned with glm::angle
|
||||
RMAPI float Vector2LineAngle(RMVector2 start, RMVector2 end)
|
||||
RMAPI float Vector2LineAngle(RLVector2 start, RLVector2 end)
|
||||
{
|
||||
float result = 0.0f;
|
||||
|
||||
@@ -357,41 +357,41 @@ RMAPI float Vector2LineAngle(RMVector2 start, RMVector2 end)
|
||||
}
|
||||
|
||||
// Scale vector (multiply by value)
|
||||
RMAPI RMVector2 Vector2Scale(RMVector2 v, float scale)
|
||||
RMAPI RLVector2 Vector2Scale(RLVector2 v, float scale)
|
||||
{
|
||||
RMVector2 result = { v.x*scale, v.y*scale };
|
||||
RLVector2 result = { v.x*scale, v.y*scale };
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// Multiply vector by vector
|
||||
RMAPI RMVector2 Vector2Multiply(RMVector2 v1, RMVector2 v2)
|
||||
RMAPI RLVector2 Vector2Multiply(RLVector2 v1, RLVector2 v2)
|
||||
{
|
||||
RMVector2 result = { v1.x*v2.x, v1.y*v2.y };
|
||||
RLVector2 result = { v1.x*v2.x, v1.y*v2.y };
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// Negate vector
|
||||
RMAPI RMVector2 Vector2Negate(RMVector2 v)
|
||||
RMAPI RLVector2 Vector2Negate(RLVector2 v)
|
||||
{
|
||||
RMVector2 result = { -v.x, -v.y };
|
||||
RLVector2 result = { -v.x, -v.y };
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// Divide vector by vector
|
||||
RMAPI RMVector2 Vector2Divide(RMVector2 v1, RMVector2 v2)
|
||||
RMAPI RLVector2 Vector2Divide(RLVector2 v1, RLVector2 v2)
|
||||
{
|
||||
RMVector2 result = { v1.x/v2.x, v1.y/v2.y };
|
||||
RLVector2 result = { v1.x/v2.x, v1.y/v2.y };
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// Normalize provided vector
|
||||
RMAPI RMVector2 Vector2Normalize(RMVector2 v)
|
||||
RMAPI RLVector2 Vector2Normalize(RLVector2 v)
|
||||
{
|
||||
RMVector2 result = { 0 };
|
||||
RLVector2 result = { 0 };
|
||||
float length = sqrtf((v.x*v.x) + (v.y*v.y));
|
||||
|
||||
if (length > 0)
|
||||
@@ -405,9 +405,9 @@ RMAPI RMVector2 Vector2Normalize(RMVector2 v)
|
||||
}
|
||||
|
||||
// Transforms a Vector2 by a given Matrix
|
||||
RMAPI RMVector2 Vector2Transform(RMVector2 v, Matrix mat)
|
||||
RMAPI RLVector2 Vector2Transform(RLVector2 v, Matrix mat)
|
||||
{
|
||||
RMVector2 result = { 0 };
|
||||
RLVector2 result = { 0 };
|
||||
|
||||
float x = v.x;
|
||||
float y = v.y;
|
||||
@@ -420,9 +420,9 @@ RMAPI RMVector2 Vector2Transform(RMVector2 v, Matrix mat)
|
||||
}
|
||||
|
||||
// Calculate linear interpolation between two vectors
|
||||
RMAPI RMVector2 Vector2Lerp(RMVector2 v1, RMVector2 v2, float amount)
|
||||
RMAPI RLVector2 Vector2Lerp(RLVector2 v1, RLVector2 v2, float amount)
|
||||
{
|
||||
RMVector2 result = { 0 };
|
||||
RLVector2 result = { 0 };
|
||||
|
||||
result.x = v1.x + amount*(v2.x - v1.x);
|
||||
result.y = v1.y + amount*(v2.y - v1.y);
|
||||
@@ -431,9 +431,9 @@ RMAPI RMVector2 Vector2Lerp(RMVector2 v1, RMVector2 v2, float amount)
|
||||
}
|
||||
|
||||
// Calculate reflected vector to normal
|
||||
RMAPI RMVector2 Vector2Reflect(RMVector2 v, RMVector2 normal)
|
||||
RMAPI RLVector2 Vector2Reflect(RLVector2 v, RLVector2 normal)
|
||||
{
|
||||
RMVector2 result = { 0 };
|
||||
RLVector2 result = { 0 };
|
||||
|
||||
float dotProduct = (v.x*normal.x + v.y*normal.y); // Dot product
|
||||
|
||||
@@ -444,9 +444,9 @@ RMAPI RMVector2 Vector2Reflect(RMVector2 v, RMVector2 normal)
|
||||
}
|
||||
|
||||
// Get min value for each pair of components
|
||||
RMAPI RMVector2 Vector2Min(RMVector2 v1, RMVector2 v2)
|
||||
RMAPI RLVector2 Vector2Min(RLVector2 v1, RLVector2 v2)
|
||||
{
|
||||
RMVector2 result = { 0 };
|
||||
RLVector2 result = { 0 };
|
||||
|
||||
result.x = fminf(v1.x, v2.x);
|
||||
result.y = fminf(v1.y, v2.y);
|
||||
@@ -455,9 +455,9 @@ RMAPI RMVector2 Vector2Min(RMVector2 v1, RMVector2 v2)
|
||||
}
|
||||
|
||||
// Get max value for each pair of components
|
||||
RMAPI RMVector2 Vector2Max(RMVector2 v1, RMVector2 v2)
|
||||
RMAPI RLVector2 Vector2Max(RLVector2 v1, RLVector2 v2)
|
||||
{
|
||||
RMVector2 result = { 0 };
|
||||
RLVector2 result = { 0 };
|
||||
|
||||
result.x = fmaxf(v1.x, v2.x);
|
||||
result.y = fmaxf(v1.y, v2.y);
|
||||
@@ -466,9 +466,9 @@ RMAPI RMVector2 Vector2Max(RMVector2 v1, RMVector2 v2)
|
||||
}
|
||||
|
||||
// Rotate vector by angle
|
||||
RMAPI RMVector2 Vector2Rotate(RMVector2 v, float angle)
|
||||
RMAPI RLVector2 Vector2Rotate(RLVector2 v, float angle)
|
||||
{
|
||||
RMVector2 result = { 0 };
|
||||
RLVector2 result = { 0 };
|
||||
|
||||
float cosres = cosf(angle);
|
||||
float sinres = sinf(angle);
|
||||
@@ -480,9 +480,9 @@ RMAPI RMVector2 Vector2Rotate(RMVector2 v, float angle)
|
||||
}
|
||||
|
||||
// Move Vector towards target
|
||||
RMAPI RMVector2 Vector2MoveTowards(RMVector2 v, RMVector2 target, float maxDistance)
|
||||
RMAPI RLVector2 Vector2MoveTowards(RLVector2 v, RLVector2 target, float maxDistance)
|
||||
{
|
||||
RMVector2 result = { 0 };
|
||||
RLVector2 result = { 0 };
|
||||
|
||||
float dx = target.x - v.x;
|
||||
float dy = target.y - v.y;
|
||||
@@ -499,18 +499,18 @@ RMAPI RMVector2 Vector2MoveTowards(RMVector2 v, RMVector2 target, float maxDista
|
||||
}
|
||||
|
||||
// Invert the given vector
|
||||
RMAPI RMVector2 Vector2Invert(RMVector2 v)
|
||||
RMAPI RLVector2 Vector2Invert(RLVector2 v)
|
||||
{
|
||||
RMVector2 result = { 1.0f/v.x, 1.0f/v.y };
|
||||
RLVector2 result = { 1.0f/v.x, 1.0f/v.y };
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// Clamp the components of the vector between
|
||||
// min and max values specified by the given vectors
|
||||
RMAPI RMVector2 Vector2Clamp(RMVector2 v, RMVector2 min, RMVector2 max)
|
||||
RMAPI RLVector2 Vector2Clamp(RLVector2 v, RLVector2 min, RLVector2 max)
|
||||
{
|
||||
RMVector2 result = { 0 };
|
||||
RLVector2 result = { 0 };
|
||||
|
||||
result.x = fminf(max.x, fmaxf(min.x, v.x));
|
||||
result.y = fminf(max.y, fmaxf(min.y, v.y));
|
||||
@@ -519,9 +519,9 @@ RMAPI RMVector2 Vector2Clamp(RMVector2 v, RMVector2 min, RMVector2 max)
|
||||
}
|
||||
|
||||
// Clamp the magnitude of the vector between two min and max values
|
||||
RMAPI RMVector2 Vector2ClampValue(RMVector2 v, float min, float max)
|
||||
RMAPI RLVector2 Vector2ClampValue(RLVector2 v, float min, float max)
|
||||
{
|
||||
RMVector2 result = v;
|
||||
RLVector2 result = v;
|
||||
|
||||
float length = (v.x*v.x) + (v.y*v.y);
|
||||
if (length > 0.0f)
|
||||
@@ -546,7 +546,7 @@ RMAPI RMVector2 Vector2ClampValue(RMVector2 v, float min, float max)
|
||||
}
|
||||
|
||||
// Check whether two given vectors are almost equal
|
||||
RMAPI int Vector2Equals(RMVector2 p, RMVector2 q)
|
||||
RMAPI int Vector2Equals(RLVector2 p, RLVector2 q)
|
||||
{
|
||||
#if !defined(EPSILON)
|
||||
#define EPSILON 0.000001f
|
||||
@@ -563,9 +563,9 @@ RMAPI int Vector2Equals(RMVector2 p, RMVector2 q)
|
||||
// n: normalized normal vector of the interface of two optical media
|
||||
// r: ratio of the refractive index of the medium from where the ray comes
|
||||
// to the refractive index of the medium on the other side of the surface
|
||||
RMAPI RMVector2 Vector2Refract(RMVector2 v, RMVector2 n, float r)
|
||||
RMAPI RLVector2 Vector2Refract(RLVector2 v, RLVector2 n, float r)
|
||||
{
|
||||
RMVector2 result = { 0 };
|
||||
RLVector2 result = { 0 };
|
||||
|
||||
float dot = v.x*n.x + v.y*n.y;
|
||||
float d = 1.0f - r*r*(1.0f - dot*dot);
|
||||
|
||||
228
src/main.cpp
228
src/main.cpp
@@ -1,24 +1,26 @@
|
||||
// Library initialisation
|
||||
#define RAYMATH_IMPLEMENTATION
|
||||
#define STB_IMAGE_IMPLEMENTATION
|
||||
#define TINYOBJ_LOADER_C_IMPLEMENTATION
|
||||
|
||||
// Project
|
||||
#include "SomaSolve.cpp"
|
||||
#include "SomaSolve.cpp"
|
||||
#include "gfx/gfx.cpp"
|
||||
#include "world/world.cpp"
|
||||
#include "VoxelSpace.cpp"
|
||||
#include "./tests.cpp"
|
||||
#include "lib/djstdlib/core.cpp"
|
||||
#include "lib/djstdlib/core.c"
|
||||
|
||||
// Graphics bindings and libs
|
||||
#include "lib/glad/glad.c"
|
||||
#include <GLFW/glfw3.h>
|
||||
|
||||
// Library initialisation
|
||||
#define STB_IMAGE_IMPLEMENTATION
|
||||
#include "lib/loaders/stb_image.h"
|
||||
#define TINYOBJ_LOADER_C_IMPLEMENTATION
|
||||
#include "lib/loaders/tinyobj.h"
|
||||
#define RAYMATH_IMPLEMENTATION
|
||||
#include "lib/raymath.h"
|
||||
#include "lib/glad/glad.c"
|
||||
#include "GLFW/glfw3.h"
|
||||
|
||||
void print(RLVector3* vector) {
|
||||
#ifdef inline
|
||||
#undef inline
|
||||
#endif
|
||||
|
||||
void printRLVec3(RLVector3* vector) {
|
||||
RLVector3 vec = *vector;
|
||||
print(
|
||||
"┌ ┐\n"
|
||||
@@ -27,7 +29,7 @@ void print(RLVector3* vector) {
|
||||
vec.x, vec.y, vec.z);
|
||||
}
|
||||
|
||||
void print(Matrix* matrix) {
|
||||
void printMatrix(Matrix* matrix) {
|
||||
Matrix mat = *matrix;
|
||||
print(
|
||||
"┌ ┐\n"
|
||||
@@ -42,15 +44,15 @@ void print(Matrix* matrix) {
|
||||
mat.m12, mat.m13, mat.m14, mat.m15);
|
||||
}
|
||||
|
||||
struct Camera {
|
||||
typedef struct {
|
||||
Matrix view;
|
||||
Matrix proj;
|
||||
RLVector3 pos;
|
||||
RLVector3 up;
|
||||
RLVector3 target;
|
||||
};
|
||||
} Camera;
|
||||
|
||||
Camera *createCamera(Arena *arena, real32 aspect_ratio = 800.0f / 600.0f) {
|
||||
Camera *createCamera(Arena *arena, real32 aspect_ratio) {
|
||||
Camera *result = PushStruct(arena, Camera);
|
||||
result->view = (Matrix){0};
|
||||
result->proj = MatrixPerspective(DEG2RAD * 45.0f, aspect_ratio, 0.1f, 100.0f);
|
||||
@@ -68,44 +70,49 @@ void cameraSetUp(Camera *c, real32 up_x, real32 up_y, real32 up_z) {
|
||||
c->up = (RLVector3){up_x, up_y, up_z};
|
||||
}
|
||||
|
||||
struct Frame {
|
||||
typedef struct {
|
||||
uint32 width;
|
||||
uint32 height;
|
||||
int32 x;
|
||||
int32 y;
|
||||
Camera* cam;
|
||||
};
|
||||
} Frame;
|
||||
|
||||
struct Polycube {
|
||||
typedef struct {
|
||||
uint32 entityHandle;
|
||||
Space repr;
|
||||
Vector4<real32> color;
|
||||
};
|
||||
RLVector4 color;
|
||||
} Polycube;
|
||||
DefineList(Polycube, Polycube);
|
||||
|
||||
struct RenderObjects_Rectangle {
|
||||
DefineList(RLVector2, RLVec2);
|
||||
DefineList(RLVector4, RLVec4);
|
||||
DefineList(real32, Float);
|
||||
|
||||
typedef struct {
|
||||
uint32 vao;
|
||||
uint64 count;
|
||||
|
||||
list<Vector2<real32>> p0;
|
||||
RLVec2List p0;
|
||||
uint32 p0BufferId;
|
||||
|
||||
list<Vector2<real32>> p1;
|
||||
RLVec2List p1;
|
||||
uint32 p1BufferId;
|
||||
|
||||
list<Vector4<real32>> color;
|
||||
RLVec4List color;
|
||||
uint32 colorBufferId;
|
||||
|
||||
list<real32> borderRadius;
|
||||
FloatList borderRadius;
|
||||
uint32 borderRadiusBufferId;
|
||||
|
||||
list<real32> borderThickness;
|
||||
FloatList borderThickness;
|
||||
uint32 borderThicknessBufferId;
|
||||
|
||||
list<real32> edgeSoftness;
|
||||
FloatList edgeSoftness;
|
||||
uint32 edgeSoftnessBufferId;
|
||||
};
|
||||
} RenderObjects_Rectangle;
|
||||
|
||||
struct Input {
|
||||
typedef struct {
|
||||
struct {
|
||||
bool escape;
|
||||
bool enter;
|
||||
@@ -121,38 +128,39 @@ struct Input {
|
||||
real32 x;
|
||||
real32 y;
|
||||
};
|
||||
Vector2<real32> point;
|
||||
RLVector2 point;
|
||||
};
|
||||
bool btnLeft;
|
||||
bool btnRight;
|
||||
bool btnMiddle;
|
||||
} mouse;
|
||||
};
|
||||
} Input;
|
||||
|
||||
struct Renderer {
|
||||
typedef struct {
|
||||
Scene *scene;
|
||||
RenderObjects_Rectangle rects;
|
||||
};
|
||||
} Renderer;
|
||||
|
||||
struct PolycubeInput {
|
||||
typedef struct {
|
||||
Space repr;
|
||||
Vector4<real32> color;
|
||||
};
|
||||
RLVector4 color;
|
||||
} PolycubeInput;
|
||||
DefineList(PolycubeInput, PolycubeInput);
|
||||
|
||||
struct SomaState {
|
||||
typedef struct {
|
||||
bool wireframe;
|
||||
bool polycubeDirty;
|
||||
uint32 currentPolycube;
|
||||
uint32 lastPolycubeVisible;
|
||||
uint32 light;
|
||||
list<Polycube> polycubes;
|
||||
PolycubeList polycubes;
|
||||
Camera* camera;
|
||||
RLVector3 rotAxisX;
|
||||
RLVector3 rotAxisY;
|
||||
list<PolycubeInput> polycubeInput;
|
||||
};
|
||||
PolycubeInputList polycubeInput;
|
||||
} SomaState;
|
||||
|
||||
struct Soma {
|
||||
typedef struct {
|
||||
Scene *scene;
|
||||
Renderer *renderer;
|
||||
SomaState state;
|
||||
@@ -163,7 +171,7 @@ struct Soma {
|
||||
uint32 width;
|
||||
uint32 height;
|
||||
} window;
|
||||
};
|
||||
} Soma;
|
||||
|
||||
void showEntity(Scene *scene, uint32 entityHandle) {
|
||||
SceneGraphNode *node = getSceneGraphNodeForEntity(scene, entityHandle);
|
||||
@@ -189,12 +197,12 @@ void hideEntity(Scene *scene, uint32 entityHandle) {
|
||||
|
||||
RLVector3 centreFromPolycube(Scene *scene, Polycube *p) {
|
||||
RLVector3 centre = (RLVector3){0,0,0};
|
||||
list<uint32> *children = &getSceneGraphNode(scene, p->entityHandle)->children;
|
||||
HandleList *children = &getSceneGraphNode(scene, p->entityHandle)->children;
|
||||
for (EachIn(*children, i)) {
|
||||
uint32 child = children->data[i];
|
||||
centre = Vector3Add(centre, getSceneGraphNode(scene, child)->translation);
|
||||
}
|
||||
centre = Vector3Scale(centre, 1.0f/(getSceneGraphNodeForEntity(scene, p->entityHandle)->children.head));
|
||||
centre = Vector3Scale(centre, 1.0f/(getSceneGraphNodeForEntity(scene, p->entityHandle)->children.length));
|
||||
return centre;
|
||||
}
|
||||
|
||||
@@ -242,21 +250,21 @@ void updateViewportFromFrame(uint32 windowWidth, uint32 windowHeight, Frame* fra
|
||||
glViewport(frame->x, windowHeight - frame->y - frame->height, frame->width, frame->height);
|
||||
}
|
||||
|
||||
struct UI_Context {
|
||||
typedef struct {
|
||||
Renderer *renderer;
|
||||
Input *prevInput;
|
||||
Input *input;
|
||||
bool cursorIsPointer;
|
||||
};
|
||||
} UI_Context;
|
||||
|
||||
struct UI_Rect {
|
||||
typedef struct {
|
||||
real32 x;
|
||||
real32 y;
|
||||
real32 width;
|
||||
real32 height;
|
||||
real32 borderRadius;
|
||||
Vector4<real32> color;
|
||||
};
|
||||
RLVector4 color;
|
||||
} UI_Rect;
|
||||
|
||||
Mesh cubeMesh = {0};
|
||||
Texture wallTex = {0};
|
||||
@@ -264,7 +272,7 @@ Texture wallTex = {0};
|
||||
Shader solidColorShader;
|
||||
Shader phongShader;
|
||||
|
||||
inline bool glfwMouse(GLFWwindow *window, int mouseBtnCode) {
|
||||
bool glfwMouse(GLFWwindow *window, int mouseBtnCode) {
|
||||
switch (glfwGetMouseButton(window, mouseBtnCode)) {
|
||||
case GLFW_RELEASE: return false;
|
||||
case GLFW_PRESS: return true;
|
||||
@@ -272,7 +280,7 @@ inline bool glfwMouse(GLFWwindow *window, int mouseBtnCode) {
|
||||
}
|
||||
}
|
||||
|
||||
inline bool glfwKey(GLFWwindow *window, int keyCode) {
|
||||
bool glfwKey(GLFWwindow *window, int keyCode) {
|
||||
switch (glfwGetKey(window, keyCode)) {
|
||||
case GLFW_RELEASE: return false;
|
||||
case GLFW_PRESS: return true;
|
||||
@@ -298,7 +306,7 @@ Input getCurrentInput(GLFWwindow *window) {
|
||||
real64 mouseX;
|
||||
real64 mouseY;
|
||||
glfwGetCursorPos(window, &mouseX, &mouseY);
|
||||
input.mouse.point = vec2<real32>((real32)mouseX, (real32)mouseY);
|
||||
input.mouse.point = (RLVector2){(real32)mouseX, (real32)mouseY};
|
||||
|
||||
return input;
|
||||
}
|
||||
@@ -347,7 +355,7 @@ void processInput(Soma *soma) {
|
||||
}
|
||||
}
|
||||
|
||||
Polycube createPolycubeFromRepr(Arena *arena, Scene *s, Space *repr, Vector4<real32> color) {
|
||||
Polycube createPolycubeFromRepr(Arena *arena, Scene *s, Space *repr, RLVector4 color) {
|
||||
uint32 polycubeMainEntityHandle = createEntity(arena, s);
|
||||
Entity *polycubeMainEntity = getEntity(s, polycubeMainEntityHandle);
|
||||
for (int x = 0; x < repr->dim_x; x++) {
|
||||
@@ -359,7 +367,7 @@ Polycube createPolycubeFromRepr(Arena *arena, Scene *s, Space *repr, Vector4<rea
|
||||
polycubeSegment->mesh = &cubeMesh;
|
||||
polycubeSegment->tex = &wallTex;
|
||||
SceneGraphNode *graphNode = getSceneGraphNode(s, polycubeSegment->graphNodeHandle);
|
||||
graphNode->translation = RLVector3{
|
||||
graphNode->translation = (RLVector3){
|
||||
-((repr->dim_z - 1)/2.0f) + z,
|
||||
-((repr->dim_x - 1)/2.0f) + x,
|
||||
((repr->dim_y - 1)/2.0f) - y
|
||||
@@ -383,12 +391,12 @@ RenderObjects_Rectangle createRectangleObjects(Arena *arena, size_t count) {
|
||||
RenderObjects_Rectangle result = {0};
|
||||
result.count = count;
|
||||
|
||||
result.p0 = PushFullList(arena, Vector2<real32>, count);
|
||||
result.p1 = PushFullList(arena, Vector2<real32>, count);
|
||||
result.color = PushFullList(arena, Vector4<real32>, count);
|
||||
result.borderRadius = PushFullList(arena, real32, count);
|
||||
result.borderThickness = PushFullList(arena, real32, count);
|
||||
result.edgeSoftness = PushFullList(arena, real32, count);
|
||||
result.p0 = PushFullList(arena, RLVec2List, count);
|
||||
result.p1 = PushFullList(arena, RLVec2List, count);
|
||||
result.color = PushFullList(arena, RLVec4List, count);
|
||||
result.borderRadius = PushFullList(arena, FloatList, count);
|
||||
result.borderThickness = PushFullList(arena, FloatList, count);
|
||||
result.edgeSoftness = PushFullList(arena, FloatList, count);
|
||||
|
||||
glGenVertexArrays(1, &result.vao);
|
||||
|
||||
@@ -402,38 +410,38 @@ RenderObjects_Rectangle createRectangleObjects(Arena *arena, size_t count) {
|
||||
glBindVertexArray(result.vao);
|
||||
|
||||
glBindBuffer(GL_ARRAY_BUFFER, result.p0BufferId);
|
||||
glBufferData(GL_ARRAY_BUFFER, result.p0.length * sizeof(Vector2<real32>), 0, GL_DYNAMIC_DRAW);
|
||||
glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, sizeof(Vector2<real32>), (void*)0);
|
||||
glBufferData(GL_ARRAY_BUFFER, result.p0.length * sizeof(RLVector2), 0, GL_DYNAMIC_DRAW);
|
||||
glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, sizeof(RLVector2), (void*)0);
|
||||
glVertexAttribDivisor(0, 1);
|
||||
glEnableVertexAttribArray(0);
|
||||
|
||||
glBindBuffer(GL_ARRAY_BUFFER, result.p1BufferId);
|
||||
glBufferData(GL_ARRAY_BUFFER, result.p1.length * sizeof(Vector2<real32>), 0, GL_DYNAMIC_DRAW);
|
||||
glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, sizeof(Vector2<real32>), (void*)0);
|
||||
glBufferData(GL_ARRAY_BUFFER, result.p1.length * sizeof(RLVector2), 0, GL_DYNAMIC_DRAW);
|
||||
glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, sizeof(RLVector2), (void*)0);
|
||||
glVertexAttribDivisor(1, 1);
|
||||
glEnableVertexAttribArray(1);
|
||||
|
||||
glBindBuffer(GL_ARRAY_BUFFER, result.colorBufferId);
|
||||
glBufferData(GL_ARRAY_BUFFER, result.color.length * sizeof(Vector4<real32>), 0, GL_DYNAMIC_DRAW);
|
||||
glVertexAttribPointer(2, 4, GL_FLOAT, GL_FALSE, sizeof(Vector4<real32>), (void*)0);
|
||||
glBufferData(GL_ARRAY_BUFFER, result.color.length * sizeof(RLVector4), 0, GL_DYNAMIC_DRAW);
|
||||
glVertexAttribPointer(2, 4, GL_FLOAT, GL_FALSE, sizeof(RLVector4), (void*)0);
|
||||
glVertexAttribDivisor(2, 1);
|
||||
glEnableVertexAttribArray(2);
|
||||
|
||||
glBindBuffer(GL_ARRAY_BUFFER, result.borderRadiusBufferId);
|
||||
glBufferData(GL_ARRAY_BUFFER, result.borderRadius.length * sizeof(real32), 0, GL_DYNAMIC_DRAW);
|
||||
glVertexAttribPointer(3, 1, GL_FLOAT, GL_FALSE, sizeof(real32), (void*)0);
|
||||
glBufferData(GL_ARRAY_BUFFER, result.borderRadius.length * sizeof(FloatList_underlying), 0, GL_DYNAMIC_DRAW);
|
||||
glVertexAttribPointer(3, 1, GL_FLOAT, GL_FALSE, sizeof(FloatList_underlying), (void*)0);
|
||||
glVertexAttribDivisor(3, 1);
|
||||
glEnableVertexAttribArray(3);
|
||||
|
||||
glBindBuffer(GL_ARRAY_BUFFER, result.borderThicknessBufferId);
|
||||
glBufferData(GL_ARRAY_BUFFER, result.borderThickness.length * sizeof(real32), 0, GL_DYNAMIC_DRAW);
|
||||
glVertexAttribPointer(4, 1, GL_FLOAT, GL_FALSE, sizeof(real32), (void*)0);
|
||||
glBufferData(GL_ARRAY_BUFFER, result.borderThickness.length * sizeof(FloatList_underlying), 0, GL_DYNAMIC_DRAW);
|
||||
glVertexAttribPointer(4, 1, GL_FLOAT, GL_FALSE, sizeof(FloatList_underlying), (void*)0);
|
||||
glVertexAttribDivisor(4, 1);
|
||||
glEnableVertexAttribArray(4);
|
||||
|
||||
glBindBuffer(GL_ARRAY_BUFFER, result.edgeSoftnessBufferId);
|
||||
glBufferData(GL_ARRAY_BUFFER, result.edgeSoftness.length * sizeof(real32), 0, GL_DYNAMIC_DRAW);
|
||||
glVertexAttribPointer(5, 1, GL_FLOAT, GL_FALSE, sizeof(real32), (void*)0);
|
||||
glBufferData(GL_ARRAY_BUFFER, result.edgeSoftness.length * sizeof(FloatList_underlying), 0, GL_DYNAMIC_DRAW);
|
||||
glVertexAttribPointer(5, 1, GL_FLOAT, GL_FALSE, sizeof(FloatList_underlying), (void*)0);
|
||||
glVertexAttribDivisor(5, 1);
|
||||
glEnableVertexAttribArray(5);
|
||||
|
||||
@@ -444,22 +452,22 @@ void reinitRectangleObjectBuffers(Renderer *r) {
|
||||
glBindVertexArray(r->rects.vao);
|
||||
|
||||
glBindBuffer(GL_ARRAY_BUFFER, r->rects.p0BufferId);
|
||||
glBufferSubData(GL_ARRAY_BUFFER, 0, r->rects.p0.head * sizeof(Vector2<real32>), r->rects.p0.data);
|
||||
glBufferSubData(GL_ARRAY_BUFFER, 0, r->rects.p0.length * sizeof(RLVec2List), r->rects.p0.data);
|
||||
|
||||
glBindBuffer(GL_ARRAY_BUFFER, r->rects.p1BufferId);
|
||||
glBufferSubData(GL_ARRAY_BUFFER, 0, r->rects.p1.head * sizeof(Vector2<real32>), r->rects.p1.data);
|
||||
glBufferSubData(GL_ARRAY_BUFFER, 0, r->rects.p1.length * sizeof(RLVec2List), r->rects.p1.data);
|
||||
|
||||
glBindBuffer(GL_ARRAY_BUFFER, r->rects.colorBufferId);
|
||||
glBufferSubData(GL_ARRAY_BUFFER, 0, r->rects.color.head * sizeof(Vector4<real32>), r->rects.color.data);
|
||||
glBufferSubData(GL_ARRAY_BUFFER, 0, r->rects.color.length * sizeof(RLVec4List), r->rects.color.data);
|
||||
|
||||
glBindBuffer(GL_ARRAY_BUFFER, r->rects.borderRadiusBufferId);
|
||||
glBufferSubData(GL_ARRAY_BUFFER, 0, r->rects.borderRadius.head * sizeof(real32), r->rects.borderRadius.data);
|
||||
glBufferSubData(GL_ARRAY_BUFFER, 0, r->rects.borderRadius.length * sizeof(FloatList), r->rects.borderRadius.data);
|
||||
|
||||
glBindBuffer(GL_ARRAY_BUFFER, r->rects.borderThicknessBufferId);
|
||||
glBufferSubData(GL_ARRAY_BUFFER, 0, r->rects.borderThickness.head * sizeof(real32), r->rects.borderThickness.data);
|
||||
glBufferSubData(GL_ARRAY_BUFFER, 0, r->rects.borderThickness.length * sizeof(FloatList), r->rects.borderThickness.data);
|
||||
|
||||
glBindBuffer(GL_ARRAY_BUFFER, r->rects.edgeSoftnessBufferId);
|
||||
glBufferSubData(GL_ARRAY_BUFFER, 0, r->rects.edgeSoftness.head * sizeof(real32), r->rects.edgeSoftness.data);
|
||||
glBufferSubData(GL_ARRAY_BUFFER, 0, r->rects.edgeSoftness.length * sizeof(FloatList), r->rects.edgeSoftness.data);
|
||||
}
|
||||
|
||||
Renderer createRenderer(Arena *arena, Scene *scene) {
|
||||
@@ -472,12 +480,12 @@ Renderer createRenderer(Arena *arena, Scene *scene) {
|
||||
}
|
||||
|
||||
void renderBegin(Renderer *r) {
|
||||
r->rects.p0.head = 0;
|
||||
r->rects.p1.head = 0;
|
||||
r->rects.color.head = 0;
|
||||
r->rects.borderRadius.head = 0;
|
||||
r->rects.borderThickness.head = 0;
|
||||
r->rects.edgeSoftness.head = 0;
|
||||
r->rects.p0.length = 0;
|
||||
r->rects.p1.length = 0;
|
||||
r->rects.color.length = 0;
|
||||
r->rects.borderRadius.length = 0;
|
||||
r->rects.borderThickness.length = 0;
|
||||
r->rects.edgeSoftness.length = 0;
|
||||
}
|
||||
|
||||
void renderEnd(Soma *soma, Renderer *renderer) {
|
||||
@@ -502,7 +510,7 @@ void renderEnd(Soma *soma, Renderer *renderer) {
|
||||
for (EachIn(renderer->scene->entities, i)) {
|
||||
Entity *entity = &renderer->scene->entities.data[i];
|
||||
if (entity->flags & EntityFlags_Render && entity->flags & EntityFlags_Visible) {
|
||||
setUniformMat4fv(model_uniform, &getSceneGraphNode(renderer->scene, entity->graphNodeHandle)->world);
|
||||
setUniformMat4fvByLoc(model_uniform, &getSceneGraphNode(renderer->scene, entity->graphNodeHandle)->world);
|
||||
glBindTexture(GL_TEXTURE_2D, entity->tex->tex_id);
|
||||
glDrawArrays(GL_TRIANGLES, 0, (GLsizei)entity->mesh->num_indices);
|
||||
entity->flags &= ~EntityFlags_Render;
|
||||
@@ -518,19 +526,21 @@ void renderEnd(Soma *soma, Renderer *renderer) {
|
||||
setUniformMat4fv(&solidColorShader, "projection", &ortho);
|
||||
|
||||
glBindVertexArray(renderer->rects.vao);
|
||||
glDrawArraysInstanced(GL_TRIANGLE_STRIP, 0, 4, renderer->rects.p0.head);
|
||||
glDrawArraysInstanced(GL_TRIANGLE_STRIP, 0, 4, renderer->rects.p0.length);
|
||||
}
|
||||
|
||||
void rendererPlaceRectangle(Renderer *r, real32 x, real32 y, real32 width, real32 height, Vector4<real32> color, real32 borderRadius, real32 borderThickness) {
|
||||
appendList(&r->rects.p0, vec2<real32>(x, y));
|
||||
appendList(&r->rects.p1, vec2<real32>(x + width, y + height));
|
||||
appendList(&r->rects.color, color);
|
||||
appendList(&r->rects.borderRadius, borderRadius);
|
||||
appendList(&r->rects.borderThickness, borderThickness);
|
||||
appendList(&r->rects.edgeSoftness, 0.0f);
|
||||
void rendererPlaceRectangle(Renderer *r, real32 x, real32 y, real32 width, real32 height, RLVector4 color, real32 borderRadius, real32 borderThickness) {
|
||||
RLVector2 p0 = {x, y};
|
||||
AppendList(&r->rects.p0, p0);
|
||||
RLVector2 p1 = {x + width, y + height};
|
||||
AppendList(&r->rects.p1, p1);
|
||||
AppendList(&r->rects.color, color);
|
||||
AppendList(&r->rects.borderRadius, borderRadius);
|
||||
AppendList(&r->rects.borderThickness, borderThickness);
|
||||
AppendList(&r->rects.edgeSoftness, 0.0f);
|
||||
}
|
||||
|
||||
inline bool pointInRect(Vector2<real32> point, UI_Rect rect) {
|
||||
bool pointInRect(RLVector2 point, UI_Rect rect) {
|
||||
return point.x > rect.x && point.y > rect.y && point.x < (rect.x + rect.width) && point.y < (rect.y + rect.height);
|
||||
}
|
||||
|
||||
@@ -622,13 +632,13 @@ int mainGfx() {
|
||||
|
||||
soma.state.currentPolycube = 0;
|
||||
soma.state.lastPolycubeVisible = 6;
|
||||
soma.state.polycubeInput = PushListZero(arena, PolycubeInput, 64);
|
||||
soma.state.polycubes = PushListZero(arena, Polycube, 64);
|
||||
soma.state.polycubeInput = PushListZero(arena, PolycubeInputList, 64);
|
||||
soma.state.polycubes = PushListZero(arena, PolycubeList, 64);
|
||||
soma.state.light = createEntity(arena, &mainScene);
|
||||
soma.state.camera = mainFrame.cam;
|
||||
|
||||
SceneGraphNode *light = getSceneGraphNode(&mainScene, getEntity(&mainScene, soma.state.light)->graphNodeHandle);
|
||||
light->translation = RLVector3{4.0f, 6.0f, 24.0f};
|
||||
light->translation = (RLVector3){4.0f, 6.0f, 24.0f};
|
||||
|
||||
/*
|
||||
Shader solid_texture_shader = createShader(
|
||||
@@ -637,24 +647,25 @@ int mainGfx() {
|
||||
*/
|
||||
|
||||
solidColorShader = createShader(
|
||||
"./assets/shaders/2d-solid.vertex.glsl"_s,
|
||||
"./assets/shaders/2d-solid.fragment.glsl"_s);
|
||||
s("./assets/shaders/2d-solid.vertex.glsl"),
|
||||
s("./assets/shaders/2d-solid.fragment.glsl"));
|
||||
|
||||
phongShader = createShader(
|
||||
"./assets/shaders/phong-solid.vertex.glsl"_s,
|
||||
"./assets/shaders/phong-solid.fragment.glsl"_s);
|
||||
s("./assets/shaders/phong-solid.vertex.glsl"),
|
||||
s("./assets/shaders/phong-solid.fragment.glsl"));
|
||||
|
||||
cubeMesh = createMesh("./assets/models/cube.obj");
|
||||
wallTex = createTexture("./assets/textures/brick-wall.jpg");
|
||||
|
||||
for (EachInArray(STD_SOMA, i)) {
|
||||
Space voxelSpace = { STD_SOMA[i], 3, 3, 3 };
|
||||
Vector4<real32> color = colorFromIndex(i);
|
||||
appendList(&soma.state.polycubeInput, PolycubeInput{ voxelSpace, color });
|
||||
RLVector4 color = colorFromIndex(i);
|
||||
PolycubeInput input = (PolycubeInput){ voxelSpace, color };
|
||||
AppendList(&soma.state.polycubeInput, input);
|
||||
cullEmptySpace(&voxelSpace);
|
||||
Polycube polycube = createPolycubeFromRepr(arena, soma.scene, &voxelSpace, color);
|
||||
polycube.color = color;
|
||||
appendList(&soma.state.polycubes, polycube);
|
||||
AppendList(&soma.state.polycubes, polycube);
|
||||
sceneNodeAddEntity(renderer.scene, renderer.scene->sceneRoot, polycube.entityHandle);
|
||||
}
|
||||
|
||||
@@ -663,7 +674,7 @@ int mainGfx() {
|
||||
|
||||
SceneGraphNode *reference_polycube_gn = getSceneGraphNodeForEntity(soma.scene, soma.state.polycubes.data[0].entityHandle);
|
||||
Matrix worldInverse = MatrixInvert(reference_polycube_gn->world);
|
||||
soma.state.rotAxisY = Vector3Normalize(RLVector3{worldInverse.m4, worldInverse.m5, worldInverse.m6});
|
||||
soma.state.rotAxisY = Vector3Normalize((RLVector3){worldInverse.m4, worldInverse.m5, worldInverse.m6});
|
||||
RLVector3 eyes = Vector3Normalize(Vector3Subtract(soma.state.camera->pos, reference_polycube_gn->translation));
|
||||
soma.state.rotAxisX = Vector3Normalize(Vector3CrossProduct(eyes, soma.state.rotAxisY));
|
||||
|
||||
@@ -730,7 +741,8 @@ int mainGfx() {
|
||||
}
|
||||
|
||||
int main() {
|
||||
initialiseCore();
|
||||
return mainGfx();
|
||||
initialiseDjStdCore();
|
||||
test();
|
||||
return mainCmd();
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ typedef struct MismatchData {
|
||||
uint64 actual;
|
||||
uint64 expected;
|
||||
} MismatchData;
|
||||
DefineList(MismatchData, MismatchData);
|
||||
|
||||
void test() {
|
||||
{
|
||||
@@ -72,7 +73,7 @@ void test() {
|
||||
space1.dim_y=3;
|
||||
space1.dim_z=3;
|
||||
|
||||
list<Space> rotations = getUniqueRotations(arena, &space1);
|
||||
VoxelSpaceList rotations = getUniqueRotations(arena, &space1);
|
||||
Space expected_rots[] = {
|
||||
{ 30ull, 1, 2, 3 },
|
||||
{ 45ull, 1, 3, 2 },
|
||||
@@ -109,7 +110,7 @@ void test() {
|
||||
space1.dim_z=3;
|
||||
|
||||
int prism_dims[] = { 3, 3, 3 };
|
||||
list<uint64> perms = getAllPermutationsInPrism(arena, &space1, prism_dims);
|
||||
VoxelSpaceReprList perms = getAllPermutationsInPrism(arena, &space1, prism_dims);
|
||||
uint64 expected_perms[] = {
|
||||
30ull,
|
||||
240ull,
|
||||
@@ -276,41 +277,44 @@ void test() {
|
||||
31457280ull,
|
||||
};
|
||||
|
||||
list<uint64> positions1 = getAllPositionsInPrism(arena, &space1, dims);
|
||||
list<uint64> positions2 = getAllPositionsInPrism(arena, &space2, dims);
|
||||
list<uint64> positions3 = getAllPositionsInPrism(arena, &space3, dims);
|
||||
VoxelSpaceReprList positions1 = getAllPositionsInPrism(arena, &space1, dims);
|
||||
VoxelSpaceReprList positions2 = getAllPositionsInPrism(arena, &space2, dims);
|
||||
VoxelSpaceReprList positions3 = getAllPositionsInPrism(arena, &space3, dims);
|
||||
|
||||
list<MismatchData> mismatches1 = PushList(arena, MismatchData, 6);
|
||||
list<MismatchData> mismatches2 = PushList(arena, MismatchData, 6);
|
||||
list<MismatchData> mismatches3 = PushList(arena, MismatchData, 6);
|
||||
MismatchDataList mismatches1 = PushList(arena, MismatchDataList, 6);
|
||||
MismatchDataList mismatches2 = PushList(arena, MismatchDataList, 6);
|
||||
MismatchDataList mismatches3 = PushList(arena, MismatchDataList, 6);
|
||||
|
||||
for (int i = 0; i < 6; i++) {
|
||||
if (positions1.data[i] != expected_results1[i]) {
|
||||
appendList(&mismatches1, { i, positions1.data[i], expected_results1[i] });
|
||||
MismatchData data = { i, positions1.data[i], expected_results1[i] };
|
||||
AppendList(&mismatches1, data);
|
||||
}
|
||||
if (positions2.data[i] != expected_results2[i]) {
|
||||
appendList(&mismatches2, { i, positions2.data[i], expected_results2[i] });
|
||||
MismatchData data = { i, positions2.data[i], expected_results2[i] };
|
||||
AppendList(&mismatches2, data);
|
||||
}
|
||||
if (positions3.data[i] != expected_results3[i]) {
|
||||
appendList(&mismatches3, { i, positions3.data[i], expected_results3[i] });
|
||||
MismatchData data = { i, positions3.data[i], expected_results3[i] };
|
||||
AppendList(&mismatches3, data);
|
||||
}
|
||||
}
|
||||
Assert(mismatches1.head == 0);
|
||||
if (mismatches1.head > 0) {
|
||||
Assert(mismatches1.length == 0);
|
||||
if (mismatches1.length > 0) {
|
||||
print("Index - Actual - Expected\n");
|
||||
for (EachIn(mismatches1, i)) {
|
||||
print("%zu - %zu - %zu\n", mismatches1.data[i].i, mismatches1.data[i].actual, mismatches1.data[i].expected);
|
||||
}
|
||||
}
|
||||
Assert(mismatches2.head == 0);
|
||||
if (mismatches2.head > 0) {
|
||||
Assert(mismatches2.length == 0);
|
||||
if (mismatches2.length > 0) {
|
||||
print("Index - Actual - Expected\n");
|
||||
for (EachIn(mismatches2, i)) {
|
||||
print("%zu - %zu - %zu\n", mismatches2.data[i].i, mismatches2.data[i].actual, mismatches2.data[i].expected);
|
||||
}
|
||||
}
|
||||
Assert(mismatches3.head == 0);
|
||||
if (mismatches3.head > 0) {
|
||||
Assert(mismatches3.length == 0);
|
||||
if (mismatches3.length > 0) {
|
||||
print("Index - Actual - Expected\n");
|
||||
for (EachIn(mismatches3, i)) {
|
||||
print("%zu - %zu - %zu\n", mismatches3.data[i].i, mismatches3.data[i].actual, mismatches3.data[i].expected);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#include <cstring>
|
||||
#include "string.h"
|
||||
#include "scene.h"
|
||||
|
||||
Entity *getEntity(Scene *s, uint32 id) {
|
||||
@@ -14,26 +14,26 @@ SceneGraphNode *getSceneGraphNode(Scene *s, uint32 sceneGraphNodeHandle) {
|
||||
}
|
||||
|
||||
uint32 createSceneGraphNode(Arena *arena, Scene *s) {
|
||||
appendList(&s->graphNodes, (SceneGraphNode){0});
|
||||
s->graphNodes.data[s->graphNodes.head - 1].children = PushList(arena, uint32, 64);
|
||||
return (uint32)s->graphNodes.head;
|
||||
AppendList(&s->graphNodes, (SceneGraphNode){0});
|
||||
s->graphNodes.data[s->graphNodes.length - 1].children = PushList(arena, HandleList, 64);
|
||||
return (uint32)s->graphNodes.length;
|
||||
}
|
||||
|
||||
uint32 createEntity(Arena *arena, Scene *s) {
|
||||
appendList(&s->entities, (Entity){0});
|
||||
AppendList(&s->entities, (Entity){0});
|
||||
uint32 graphNodeId = createSceneGraphNode(arena, s);
|
||||
s->entities.data[s->entities.head - 1].graphNodeHandle = graphNodeId;
|
||||
getSceneGraphNode(s, graphNodeId)->entityHandle = (uint32)s->entities.head;
|
||||
uint32 handle = (uint32)s->entities.head;
|
||||
uint32 graphNodeHandle = (uint32)s->graphNodes.head;
|
||||
s->entities.data[s->entities.length - 1].graphNodeHandle = graphNodeId;
|
||||
getSceneGraphNode(s, graphNodeId)->entityHandle = (uint32)s->entities.length;
|
||||
uint32 handle = (uint32)s->entities.length;
|
||||
uint32 graphNodeHandle = (uint32)s->graphNodes.length;
|
||||
initGraphNode(getSceneGraphNode(s, graphNodeHandle));
|
||||
return handle;
|
||||
}
|
||||
|
||||
void initGraphNode(SceneGraphNode *n) {
|
||||
n->scale = RLVector3{1.0f, 1.0f, 1.0f};
|
||||
n->translation = RLVector3{0.0f, 0.0f, 0.0f};
|
||||
n->rotation = Quaternion{1.0f, 0.0f, 0.0f, 0.0f};
|
||||
n->scale = (RLVector3){1.0f, 1.0f, 1.0f};
|
||||
n->translation = (RLVector3){0.0f, 0.0f, 0.0f};
|
||||
n->rotation = (Quaternion){1.0f, 0.0f, 0.0f, 0.0f};
|
||||
n->local = MatrixIdentity();
|
||||
n->world = n->local;
|
||||
}
|
||||
@@ -44,8 +44,8 @@ void recalcGraphNode(SceneGraphNode *n) {
|
||||
|
||||
Scene createScene(Arena *arena) {
|
||||
Scene result = {};
|
||||
result.entities = PushList(arena, Entity, 1024);
|
||||
result.graphNodes = PushList(arena, SceneGraphNode, 1024);
|
||||
result.entities = PushList(arena, EntityList, 1024);
|
||||
result.graphNodes = PushList(arena, SceneGraphNodeList, 1024);
|
||||
result.sceneRoot = createSceneGraphNode(arena, &result);
|
||||
return result;
|
||||
}
|
||||
@@ -75,10 +75,10 @@ void removeEntity(Scene *s, uint32 entityHandle) {
|
||||
SceneGraphNode *graphNode = getSceneGraphNode(s, entity->graphNodeHandle);
|
||||
if (graphNode->parentHandle) {
|
||||
SceneGraphNode *parentNode = getSceneGraphNode(s, graphNode->parentHandle);
|
||||
for (int i = 0; i < parentNode->children.head; i++) {
|
||||
for (int i = 0; i < parentNode->children.length; i++) {
|
||||
if (parentNode->children.data[i] == entity->graphNodeHandle) {
|
||||
memcpy(&parentNode->children.data[i], &parentNode->children.data[i + 1], parentNode->children.head - i);
|
||||
parentNode->children.head -= 1;
|
||||
memcpy(&parentNode->children.data[i], &parentNode->children.data[i + 1], parentNode->children.length - i);
|
||||
parentNode->children.length -= 1;
|
||||
graphNode->parentHandle = 0;
|
||||
break;
|
||||
}
|
||||
@@ -87,7 +87,6 @@ void removeEntity(Scene *s, uint32 entityHandle) {
|
||||
}
|
||||
|
||||
void sceneNodeAddEntity(Scene *s, uint32 graphNodeHandle, uint32 entityHandle) {
|
||||
list<uint32> *childList = &getSceneGraphNode(s, graphNodeHandle)->children;
|
||||
appendList(childList, getEntity(s, entityHandle)->graphNodeHandle);
|
||||
print("%zu HI\n", childList->length);
|
||||
HandleList *childList = &getSceneGraphNode(s, graphNodeHandle)->children;
|
||||
AppendList(childList, getEntity(s, entityHandle)->graphNodeHandle);
|
||||
}
|
||||
|
||||
@@ -1,42 +1,46 @@
|
||||
#include "../gfx/gfx.h"
|
||||
#include "../lib/raymath.h"
|
||||
|
||||
DefineList(uint32, Handle);
|
||||
|
||||
enum EntityFlags {
|
||||
EntityFlags_Visible=1<<0,
|
||||
EntityFlags_Dead=1<<1,
|
||||
EntityFlags_Render=1<<2,
|
||||
};
|
||||
};
|
||||
|
||||
struct Entity {
|
||||
typedef struct {
|
||||
Mesh *mesh;
|
||||
Texture *tex;
|
||||
uint32 graphNodeHandle;
|
||||
uint64 flags;
|
||||
};
|
||||
} Entity;
|
||||
DefineList(Entity, Entity);
|
||||
|
||||
struct SceneGraphNode {
|
||||
typedef struct {
|
||||
Matrix local;
|
||||
Matrix world;
|
||||
RLVector3 translation;
|
||||
Quaternion rotation;
|
||||
RLVector3 scale;
|
||||
list<uint32> children;
|
||||
HandleList children;
|
||||
uint32 entityHandle;
|
||||
uint32 parentHandle;
|
||||
};
|
||||
} SceneGraphNode;
|
||||
DefineList(SceneGraphNode, SceneGraphNode);
|
||||
|
||||
struct Scene {
|
||||
typedef struct {
|
||||
uint32 sceneRoot;
|
||||
list<Entity> entities;
|
||||
list<SceneGraphNode> graphNodes;
|
||||
};
|
||||
EntityList entities;
|
||||
SceneGraphNodeList graphNodes;
|
||||
} Scene;
|
||||
|
||||
uint32 createEntity(Arena *arena, Scene *s);
|
||||
Entity *getEntity(Scene *s);
|
||||
SceneGraphNode *getSceneGraphNode(Scene *s, int id);
|
||||
Entity *getEntity(Scene *s, uint32 id);
|
||||
SceneGraphNode *getSceneGraphNode(Scene *s, uint32 id);
|
||||
uint32 createSceneGraphNode(Arena *arena, Scene *s);
|
||||
Scene createScene(Arena *arena);
|
||||
void initGraphNode(SceneGraphNode *n);
|
||||
void initGraphNode(SceneGraphNode *n);
|
||||
void recalcGraphNode(SceneGraphNode *n);
|
||||
void recalcSceneGraphNode(Scene *s, uint32 parentHandle);
|
||||
void recalcScene(Scene *s);
|
||||
|
||||
Reference in New Issue
Block a user