This commit is contained in:
aozhiwei 2020-08-18 16:11:40 +08:00
parent 8b8fb38a7c
commit 203adbe1f4
2 changed files with 38 additions and 1 deletions

View File

@ -1,5 +1,7 @@
#include "precompile.h"
#include "Recast.h"
#include "inputgeom.h"
struct BoundsItem
@ -224,7 +226,38 @@ namespace f8
void InputGeom::Init(float width, float height)
{
{
verts_.reserve(3 * 4);
verts_.push_back(0);
verts_.push_back(0);
verts_.push_back(0);
verts_.push_back(0);
verts_.push_back(0);
verts_.push_back(height);
verts_.push_back(width);
verts_.push_back(0);
verts_.push_back(height);
verts_.push_back(width);
verts_.push_back(0);
verts_.push_back(0);
}
{
tris_.push_back(0);
tris_.push_back(1);
tris_.push_back(2);
tris_.push_back(0);
tris_.push_back(2);
tris_.push_back(3);
}
rcCalcBounds(GetVerts(), GetVertCount(), min_, max_);
if (!rcCreateChunkyTriMesh(GetVerts(), GetTris(), GetTriCount(), 256, &chunky_mesh_)) {
abort();
}
}
}

View File

@ -36,13 +36,16 @@ namespace f8
const float* GetMeshBoundsMin() const { return min_; }
const float* GetMeshBoundsMax() const { return max_; }
const float* GetVerts() const { return !verts_.empty() ? &verts_[0] : nullptr; }
int GetVertCount() const { return verts_.size(); }
int GetVertCount() const { return verts_.size() / 3; }
const int* GetTris() const { return !tris_.empty() ? &tris_[0] : nullptr; }
int GetTriCount() const { return tris_.size() / 3; }
const rcChunkyTriMesh* GetChunkyMesh() { return &chunky_mesh_; }
private:
float min_[3] = {0};
float max_[3] = {0};
std::vector<float> verts_;
std::vector<int> tris_;
rcChunkyTriMesh chunky_mesh_;
};
@ -51,3 +54,4 @@ namespace f8
int rcGetChunksOverlappingRect(const rcChunkyTriMesh* cm,
float bmin[2], float bmax[2],
int* ids, const int maxIds);