~vladh/peony

peony/src/spatial.hpp -rw-r--r-- 1.2 KiB
7fc9922bVlad-Stefan Harbuz changes shaders namespace into class a month ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/*
  Peony Game Engine
  Copyright (C) 2020 Vlad-Stefan Harbuz <vlad@vladh.net>
  All rights reserved.
*/

#pragma once

#include "types.hpp"
#include "entities.hpp"

namespace spatial {
  struct Obb {
    v3 center;
    v3 x_axis;
    v3 y_axis; // We can get the z axis with a cross product
    v3 extents;
  };

  struct Face {
    v3 vertices[4];
  };

  struct Ray {
    v3 origin;
    v3 direction;
  };


  struct SpatialComponent {
    EntityHandle entity_handle;
    v3 position;
    quat rotation;
    v3 scale;
    EntityHandle parent_entity_handle;
  };


  struct ModelMatrixCache {
    m4 last_model_matrix;
    SpatialComponent *last_model_matrix_spatial_component;
  };

  struct SpatialComponentSet {
    Array<SpatialComponent> components;
  };


  void print_spatial_component(SpatialComponent *spatial_component);
  bool32 does_spatial_component_have_dimensions(SpatialComponent *spatial_component);
  bool32 is_spatial_component_valid(SpatialComponent *spatial_component);
  m4 make_model_matrix(
    SpatialComponentSet *spatial_component_set,
    SpatialComponent *spatial_component,
    ModelMatrixCache *cache
  );
}

using spatial::Obb, spatial::Face, spatial::Ray, spatial::SpatialComponent,
  spatial::ModelMatrixCache, spatial::SpatialComponentSet;