Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicholas Bishop <nicholasbishop@gmail.com>2012-05-11 00:32:51 +0400
committerNicholas Bishop <nicholasbishop@gmail.com>2012-05-11 00:32:51 +0400
commit2ca64189b734dbd289d1a07e1ce9d332eadebe19 (patch)
tree260ab5e5c95104880ff48217602cba2b70fffe3e /source/blender/blenkernel/intern/CCGSubSurf.c
parentdcacbc25bc0fb850b56673f7f167aa623d1e2fb5 (diff)
Add CCGKey/CCGElem for accessing CCGSubSurf elements.
CCGKey caches information about the CCGSubSurf element layout. This data, along with the CCG_* inline functions, allows access to CCGSubSurf elements with an arbitrary number of layers (as opposed to the hardcoded DMGridData structure which assumes xyz coordinates followed by three normal components.) The CCGElem structure is declared but not defined anywhere, just used as a convenient type.
Diffstat (limited to 'source/blender/blenkernel/intern/CCGSubSurf.c')
-rw-r--r--source/blender/blenkernel/intern/CCGSubSurf.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/source/blender/blenkernel/intern/CCGSubSurf.c b/source/blender/blenkernel/intern/CCGSubSurf.c
index db2f41aca3e..a15d5938641 100644
--- a/source/blender/blenkernel/intern/CCGSubSurf.c
+++ b/source/blender/blenkernel/intern/CCGSubSurf.c
@@ -7,6 +7,7 @@
#include <string.h>
#include <math.h>
+#include "BKE_ccg.h"
#include "CCGSubSurf.h"
#include "BKE_subsurf.h"
@@ -3101,3 +3102,30 @@ int ccgSubSurf_getNumFinalFaces(const CCGSubSurf *ss)
int numFinalFaces = ss->numGrids * ((gridSize - 1) * (gridSize - 1));
return numFinalFaces;
}
+
+/***/
+
+void CCG_key(CCGKey *key, const CCGSubSurf *ss, int level)
+{
+ key->level = level;
+
+ key->elem_size = ss->meshIFC.vertDataSize;
+ key->has_normals = ss->calcVertNormals;
+ key->num_layers = ss->meshIFC.numLayers;
+
+ /* if normals are present, always the last three floats of an
+ element */
+ if (key->has_normals)
+ key->normal_offset = key->elem_size - sizeof(float) * 3;
+ else
+ key->normal_offset = -1;
+
+ key->grid_size = ccgSubSurf_getGridLevelSize(ss, level);
+ key->grid_area = key->grid_size * key->grid_size;
+ key->grid_bytes = key->elem_size * key->grid_area;
+}
+
+void CCG_key_top_level(CCGKey *key, const CCGSubSurf *ss)
+{
+ CCG_key(key, ss, ccgSubSurf_getSubdivisionLevels(ss));
+}