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>2009-10-27 22:53:34 +0300
committerNicholas Bishop <nicholasbishop@gmail.com>2009-10-27 22:53:34 +0300
commit93beb0b85a4a0e301d9bfae9edee1fe7bdabba12 (patch)
tree1eb245707476ea83a356671c1c84ce82127581a7 /source/blender/blenkernel
parentb2c2dafb687fb3dea0b36a52d5b77695adfe5181 (diff)
Commit of the sculpt patch (#19672). Further development will be in this branch until we merge to trunk.
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r--source/blender/blenkernel/BKE_DerivedMesh.h2
-rw-r--r--source/blender/blenkernel/BKE_paint.h7
-rw-r--r--source/blender/blenkernel/intern/cdderivedmesh.c91
-rw-r--r--source/blender/blenkernel/intern/object.c10
-rw-r--r--source/blender/blenkernel/intern/subsurf_ccg.c2
5 files changed, 104 insertions, 8 deletions
diff --git a/source/blender/blenkernel/BKE_DerivedMesh.h b/source/blender/blenkernel/BKE_DerivedMesh.h
index 076747cb845..75d9ae7f360 100644
--- a/source/blender/blenkernel/BKE_DerivedMesh.h
+++ b/source/blender/blenkernel/BKE_DerivedMesh.h
@@ -204,7 +204,7 @@ struct DerivedMesh {
*
* Also called for *final* editmode DerivedMeshes
*/
- void (*drawFacesSolid)(DerivedMesh *dm,
+ void (*drawFacesSolid)(DerivedMesh *dm, void *tree, float (*partial_redraw_planes)[4],
int (*setMaterial)(int, void *attribs));
/* Draw all faces
diff --git a/source/blender/blenkernel/BKE_paint.h b/source/blender/blenkernel/BKE_paint.h
index ba42aca1872..558659b520f 100644
--- a/source/blender/blenkernel/BKE_paint.h
+++ b/source/blender/blenkernel/BKE_paint.h
@@ -34,6 +34,7 @@ struct MultireModifierData;
struct MVert;
struct Object;
struct Paint;
+struct PBVH;
struct Scene;
struct StrokeCache;
@@ -76,8 +77,10 @@ typedef struct SculptSession {
/* Used temporarily per-stroke */
float *vertexcosnos;
- ListBase damaged_rects;
- ListBase damaged_verts;
+
+ /* Partial redraw */
+ struct PBVH *tree;
+ int partial_redraw;
/* Used to cache the render of the active texture */
unsigned int texcache_side, *texcache, texcache_actual;
diff --git a/source/blender/blenkernel/intern/cdderivedmesh.c b/source/blender/blenkernel/intern/cdderivedmesh.c
index e38bb00fe8d..6ae1057767d 100644
--- a/source/blender/blenkernel/intern/cdderivedmesh.c
+++ b/source/blender/blenkernel/intern/cdderivedmesh.c
@@ -49,7 +49,7 @@
#include "BLI_blenlib.h"
#include "BLI_edgehash.h"
#include "BLI_editVert.h"
-#include "BLI_ghash.h"
+#include "BLI_pbvh.h"
#include "DNA_mesh_types.h"
#include "DNA_meshdata_types.h"
@@ -360,7 +360,68 @@ static void cdDM_drawLooseEdges(DerivedMesh *dm)
}
}
-static void cdDM_drawFacesSolid(DerivedMesh *dm, int (*setMaterial)(int, void *attribs))
+static int nodes_drawn = 0;
+static int is_partial = 0;
+/* XXX: Just a temporary replacement for the real drawing code */
+static void draw_partial_cb(const int *face_indices,
+ const int *vert_indices,
+ int totface, int totvert, void *data_v)
+{
+ /* XXX: Just some quick code to show leaf nodes in different colors */
+ /*float col[3]; int i;
+ if(is_partial) {
+ col[0] = (rand() / (float)RAND_MAX); col[1] = col[2] = 0.6;
+ }
+ else {
+ srand((long long)data_v);
+ for(i = 0; i < 3; ++i)
+ col[i] = (rand() / (float)RAND_MAX) * 0.3 + 0.7;
+ }
+ glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, col);
+
+ glColor3f(1, 0, 0);*/
+ GPU_draw_buffers(data_v);
+ ++nodes_drawn;
+}
+
+int find_all(float bb_min[3], float bb_max[3], void *data)
+{
+ return 1;
+}
+
+/* Adapted from:
+ http://www.gamedev.net/community/forums/topic.asp?topic_id=512123
+ Returns true if the AABB is at least partially within the frustum
+ (ok, not a real frustum), false otherwise.
+*/
+int planes_contain_AABB(float bb_min[3], float bb_max[3], void *data)
+{
+ float (*planes)[4] = data;
+ int i, axis;
+ float vmin[3], vmax[3];
+
+ for(i = 0; i < 4; ++i) {
+ for(axis = 0; axis < 3; ++axis) {
+ if(planes[i][axis] > 0) {
+ vmin[axis] = bb_min[axis];
+ vmax[axis] = bb_max[axis];
+ }
+ else {
+ vmin[axis] = bb_max[axis];
+ vmax[axis] = bb_min[axis];
+ }
+ }
+
+ if(Inpf(planes[i], vmin) + planes[i][3] > 0)
+ return 0;
+ }
+
+ return 1;
+}
+
+static void cdDM_drawFacesSolid(DerivedMesh *dm, void *tree,
+ float (*partial_redraw_planes)[4],
+ int (*setMaterial)(int, void *attribs))
{
CDDerivedMesh *cddm = (CDDerivedMesh*) dm;
MVert *mvert = cddm->mvert;
@@ -376,6 +437,32 @@ static void cdDM_drawFacesSolid(DerivedMesh *dm, int (*setMaterial)(int, void *a
glVertex3fv(mvert[index].co); \
}
+ if(tree) {
+ BLI_pbvh_search(tree, BLI_pbvh_update_search_cb,
+ PBVH_NodeData, NULL, NULL,
+ PBVH_SEARCH_UPDATE);
+
+ if(partial_redraw_planes) {
+ BLI_pbvh_search(tree, planes_contain_AABB,
+ partial_redraw_planes,
+ draw_partial_cb, PBVH_DrawData,
+ PBVH_SEARCH_MODIFIED);
+ }
+ else {
+ BLI_pbvh_search(tree, find_all, NULL,
+ draw_partial_cb, PBVH_DrawData,
+ PBVH_SEARCH_NORMAL);
+
+ }
+
+ is_partial = !!partial_redraw_planes;
+
+ //printf("nodes drawn=%d\n", nodes_drawn);
+ nodes_drawn = 0;
+
+ return;
+ }
+
if( GPU_buffer_legacy(dm) ) {
DEBUG_VBO( "Using legacy code. cdDM_drawFacesSolid\n" );
glBegin(glmode = GL_QUADS);
diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c
index ba8d41f54bb..5c3419fb488 100644
--- a/source/blender/blenkernel/intern/object.c
+++ b/source/blender/blenkernel/intern/object.c
@@ -72,6 +72,8 @@
#include "BLI_blenlib.h"
#include "BLI_arithb.h"
#include "BLI_editVert.h"
+#include "BLI_ghash.h"
+#include "BLI_pbvh.h"
#include "BKE_utildefines.h"
@@ -228,8 +230,6 @@ void free_sculptsession(SculptSession **ssp)
{
if(ssp && *ssp) {
SculptSession *ss = *ssp;
- if(ss->projverts)
- MEM_freeN(ss->projverts);
if(ss->fmap)
MEM_freeN(ss->fmap);
@@ -246,6 +246,12 @@ void free_sculptsession(SculptSession **ssp)
if(ss->mesh_co_orig)
MEM_freeN(ss->mesh_co_orig);
+ if(ss->tree)
+ BLI_pbvh_free(ss->tree);
+
+ if(ss->face_normals)
+ MEM_freeN(ss->face_normals);
+
MEM_freeN(ss);
*ssp = NULL;
diff --git a/source/blender/blenkernel/intern/subsurf_ccg.c b/source/blender/blenkernel/intern/subsurf_ccg.c
index 6e95fe7ebc7..7c83431ebd8 100644
--- a/source/blender/blenkernel/intern/subsurf_ccg.c
+++ b/source/blender/blenkernel/intern/subsurf_ccg.c
@@ -1615,7 +1615,7 @@ static void ccgDM_glNormalFast(float *a, float *b, float *c, float *d)
}
/* Only used by non-editmesh types */
-static void ccgDM_drawFacesSolid(DerivedMesh *dm, int (*setMaterial)(int, void *attribs)) {
+static void ccgDM_drawFacesSolid(DerivedMesh *dm, void *tree, float (*partial_redraw_planes)[4], int (*setMaterial)(int, void *attribs)) {
CCGDerivedMesh *ccgdm = (CCGDerivedMesh*) dm;
CCGSubSurf *ss = ccgdm->ss;
CCGFaceIterator *fi = ccgSubSurf_getFaceIterator(ss);