Added Constructor and Destructor to rcHeightfield.
This commit is contained in:
parent
d9c6fc58ce
commit
61dbce80e9
@ -293,6 +293,9 @@ struct rcSpanPool
|
||||
/// @ingroup recast
|
||||
struct rcHeightfield
|
||||
{
|
||||
rcHeightfield();
|
||||
~rcHeightfield();
|
||||
|
||||
int width; ///< The width of the heightfield. (Along the x-axis in cell units.)
|
||||
int height; ///< The height of the heightfield. (Along the z-axis in cell units.)
|
||||
float bmin[3]; ///< The minimum bounds in world space. [(x, y, z)]
|
||||
@ -302,6 +305,11 @@ struct rcHeightfield
|
||||
rcSpan** spans; ///< Heightfield of spans (width*height).
|
||||
rcSpanPool* pools; ///< Linked list of span pools.
|
||||
rcSpan* freelist; ///< The next free span.
|
||||
|
||||
private:
|
||||
// Explicitly-disabled copy constructor and copy assignment operator.
|
||||
rcHeightfield(const rcHeightfield&);
|
||||
rcHeightfield& operator=(const rcHeightfield&);
|
||||
};
|
||||
|
||||
/// Provides information on the content of a cell column in a compact heightfield.
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <new>
|
||||
#include "Recast.h"
|
||||
#include "RecastAlloc.h"
|
||||
#include "RecastAssert.h"
|
||||
@ -72,23 +73,39 @@ void rcContext::log(const rcLogCategory category, const char* format, ...)
|
||||
|
||||
rcHeightfield* rcAllocHeightfield()
|
||||
{
|
||||
rcHeightfield* hf = (rcHeightfield*)rcAlloc(sizeof(rcHeightfield), RC_ALLOC_PERM);
|
||||
memset(hf, 0, sizeof(rcHeightfield));
|
||||
return hf;
|
||||
return new (rcAlloc(sizeof(rcHeightfield), RC_ALLOC_PERM)) rcHeightfield;
|
||||
}
|
||||
|
||||
rcHeightfield::rcHeightfield()
|
||||
: width()
|
||||
, height()
|
||||
, bmin()
|
||||
, bmax()
|
||||
, cs()
|
||||
, ch()
|
||||
, spans()
|
||||
, pools()
|
||||
, freelist()
|
||||
{
|
||||
}
|
||||
|
||||
rcHeightfield::~rcHeightfield()
|
||||
{
|
||||
// Delete span array.
|
||||
rcFree(spans);
|
||||
// Delete span pools.
|
||||
while (pools)
|
||||
{
|
||||
rcSpanPool* next = pools->next;
|
||||
rcFree(pools);
|
||||
pools = next;
|
||||
}
|
||||
}
|
||||
|
||||
void rcFreeHeightField(rcHeightfield* hf)
|
||||
{
|
||||
if (!hf) return;
|
||||
// Delete span array.
|
||||
rcFree(hf->spans);
|
||||
// Delete span pools.
|
||||
while (hf->pools)
|
||||
{
|
||||
rcSpanPool* next = hf->pools->next;
|
||||
rcFree(hf->pools);
|
||||
hf->pools = next;
|
||||
}
|
||||
hf->~rcHeightfield();
|
||||
rcFree(hf);
|
||||
}
|
||||
|
||||
@ -109,7 +126,6 @@ void rcFreeCompactHeightfield(rcCompactHeightfield* chf)
|
||||
rcFree(chf);
|
||||
}
|
||||
|
||||
|
||||
rcHeightfieldLayerSet* rcAllocHeightfieldLayerSet()
|
||||
{
|
||||
rcHeightfieldLayerSet* lset = (rcHeightfieldLayerSet*)rcAlloc(sizeof(rcHeightfieldLayerSet), RC_ALLOC_PERM);
|
||||
|
Loading…
x
Reference in New Issue
Block a user