PhysicsData.h
1 /************************************************************
2 * (C) Voxel Farm Inc. 2015
3 */
4 
5 #pragma once
6 
7 #include "VoxelFarmConfig.h"
8 #include "mapindex.h"
9 #include "CellData.h"
10 #include "PhysicsMaterials.h"
11 
12 // contains various common data structures used in the physics/stampmesh pipeline
13 
14 namespace VoxelFarm
15 {
16  namespace Physics
17  {
18  // records the number of voxels per material class
19  struct CMassInfo
20  {
21  int totalVoxels = 0;
22  int* perMatVoxels;
23  CMassInfo()
24  {
25  perMatVoxels = (int*)VF_RAWCALLOC(cMATCLASSES, sizeof(int));
26  }
27  ~CMassInfo()
28  {
29  VF_FREE(perMatVoxels);
30  }
31  };
32 
33  // container for noiseBrush
34  struct CNoiseBrush
35  {
36  ~CNoiseBrush()
37  {
38  VF_FREE(field);
39  }
40  unsigned short dimension[2]; // 0 -> cube side length; 1 -> number of worley cells
41  unsigned short* field; // "bit" field defining the mesh
42  };
43 
44  // container for voxelBuffer
46  {
47  public:
48  void clear()
49  {
50  voxelRanges.clear();
51  voxelIds.clear();
52  }
53  struct nVoxel
54  {
55  unsigned char v[3]; // voxel vector
56  int type; // associated fragment type
57  };
58  struct nVoxelRange
59  {
60  int cellId = INT_MIN; // cell padding used to compute voxel ids within the cell
61  double pos[3]; // world pos of the cell
62 
63  // ranges
64  int minx = INT_MAX;
65  int miny = INT_MAX;
66  int minz = INT_MAX;
67  int maxx = INT_MIN;
68  int maxy = INT_MIN;
69  int maxz = INT_MIN;
70  };
71  TMap<int, nVoxelRange> voxelRanges; // maps fragment type -> min/max voxel in (x,y,z)
72  TMap<int, nVoxel> voxelIds; // maps a unique voxel id -> voxel container
73  int material = -1; // hit position material id
74  };
75 
76  // container for fragment render meshes
77  struct CMovingSolid
78  {
79  CCellData* mesh;
80  double origin[3];
81  double shift[3];
82  double scale[3];
83  double transform[16];
84  double rot[4];
85  clock_t clock;
86  double buoyantForce;
87  char material;
88  CMovingSolid()
89  {
90  rot[0] = 0;
91  rot[1] = 0;
92  rot[2] = 0;
93  rot[3] = 1;
94  buoyantForce = -1;
95  material = -1;
96  };
97  };
98  };
99 };
Contains all classes and functions for the VoxelFarm engine.
Stores the information for a Cell that has already been converted to a polygonal mesh.
Definition: CellData.h:107