Add new CCG accessor functions.

ccg_gridsize() converts a level into gridsize, ccg_factor() is for
converting coordinates between different multires levels.
This commit is contained in:
Nicholas Bishop 2012-03-14 06:31:24 +00:00
parent 7f2acc173e
commit 0c91821364
3 changed files with 20 additions and 2 deletions

@ -31,6 +31,9 @@
* \ingroup bke
*/
/* struct DerivedMesh is used directly */
#include "BKE_DerivedMesh.h"
struct DMFlagMat;
struct DMGridAdjacency;
struct DMGridData;
@ -61,6 +64,13 @@ struct DerivedMesh *subsurf_make_derived_from_derived(
void subsurf_calculate_limit_positions(struct Mesh *me, float (*positions_r)[3]);
/* get gridsize from 'level', level must be greater than zero */
int ccg_gridsize(int level);
/* x/y grid coordinates at 'low_level' can be multiplied by the result
of this function to convert to grid coordinates at 'high_level' */
int ccg_factor(int low_level, int high_level);
/**************************** Internal *****************************/
typedef struct CCGDerivedMesh {

@ -8,6 +8,7 @@
#include <math.h>
#include "CCGSubSurf.h"
#include "BKE_subsurf.h"
#include "MEM_guardedalloc.h"
#include "BLO_sys_types.h" // for intptr_t support
@ -227,7 +228,7 @@ static CCGAllocatorIFC *_getStandardAllocatorIFC(void)
/***/
static int ccg_gridsize(int level)
int ccg_gridsize(int level)
{
BLI_assert(level > 0);
BLI_assert(level <= 31);
@ -235,6 +236,14 @@ static int ccg_gridsize(int level)
return (1 << (level - 1)) + 1;
}
int ccg_factor(int low_level, int high_level)
{
BLI_assert(low_level > 0 && high_level > 0);
BLI_assert(low_level <= high_level);
return 1 << (high_level - low_level);
}
static int ccg_edgesize(int level)
{
BLI_assert(level > 0);

@ -3388,4 +3388,3 @@ void subsurf_calculate_limit_positions(Mesh *me, float (*positions_r)[3])
dm->release(dm);
}