Nebula
Loading...
Searching...
No Matches
geometry.h
Go to the documentation of this file.
1#pragma once
2//------------------------------------------------------------------------------
15//------------------------------------------------------------------------------
16#include "core/types.h"
17#include "util/array.h"
18#include "util/stringatom.h"
19#include "flat/physics/material.h"
20
21#include <functional>
22
23namespace Physics
24{
25
32
33//------------------------------------------------------------------------------
37inline SizeT
39{
40 switch (type)
41 {
42 case Physics::IndexType::Index16: return sizeof(uint16_t);
43 case Physics::IndexType::Index32: return sizeof(uint32_t);
44 default: return 0;
45 }
46}
47
50{
51 Util::Array<float> positions; // 3 floats per vertex
52 SizeT vertexCount = 0; // positions.Size() == vertexCount * 3
53 SizeT positionStride = sizeof(float) * 3;
54
55 Util::Array<byte> indices; // indexCount indices of IndexSize() bytes each, triangle triplets
58
59 // These can be used for the ApproxSkin topology, where every bone gets its own convex hull.
60 Util::Array<float> weights; // 4 floats per vertex, empty when not skinned
61 Util::Array<uint> bones; // one bone per vertex, empty when not skinned
62
63 Physics::MeshTopology topology = Physics::MeshTopology_Triangles;
64};
65
68{
71 Util::Array<ushort> samples; // width * height samples
72};
73
76{
77 std::function<bool(Util::StringAtom resource, IndexT primGroup, MeshGeometryInput& out)> LoadMesh = nullptr;
78 std::function<bool(Util::StringAtom resource, HeightFieldInput& out)> LoadHeightField = nullptr;
79};
80
82void SetGeometryLoader(const GeometryLoader& loader);
85
86} // namespace Physics
87//------------------------------------------------------------------------------
Nebula's dynamic array class.
Definition array.h:61
A StringAtom.
Definition stringatom.h:22
Diverse functions for manipulating physics actors.
Definition actorcontext.cc:22
void SetGeometryLoader(const GeometryLoader &loader)
register the geometry loader to use
Definition geometry.cc:17
SizeT IndexSize(Physics::IndexType type)
Byte size of an index type.
Definition geometry.h:38
const GeometryLoader & GetGeometryLoader()
get the currently registered geometry loader
Definition geometry.cc:26
IndexType
Definition geometry.h:27
@ Index32
Definition geometry.h:30
@ InvalidIndexType
Definition geometry.h:28
@ Index16
Definition geometry.h:29
Holds function pointers for reading meshes and heightfields from resources.
Definition geometry.h:76
std::function< bool(Util::StringAtom resource, HeightFieldInput &out)> LoadHeightField
Definition geometry.h:78
std::function< bool(Util::StringAtom resource, IndexT primGroup, MeshGeometryInput &out)> LoadMesh
Definition geometry.h:77
Height field samples for the cooking layer.
Definition geometry.h:68
SizeT width
Definition geometry.h:69
Util::Array< ushort > samples
Definition geometry.h:71
SizeT height
Definition geometry.h:70
Triangle geometry for the cooking layer.
Definition geometry.h:50
Util::Array< float > weights
Definition geometry.h:60
SizeT vertexCount
Definition geometry.h:52
Util::Array< float > positions
Definition geometry.h:51
SizeT indexCount
Definition geometry.h:56
Util::Array< uint > bones
Definition geometry.h:61
Util::Array< byte > indices
Definition geometry.h:55
Physics::MeshTopology topology
Definition geometry.h:63
Physics::IndexType indexType
Definition geometry.h:57
SizeT positionStride
Definition geometry.h:53
int SizeT
Definition types.h:42
int IndexT
Definition types.h:41