[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [37159] branches/soc-2011-onion: Revision: 29483
Jason Wilkins
Jason.A.Wilkins at gmail.com
Sat Jun 4 05:27:40 CEST 2011
Revision: 37159
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=37159
Author: jwilkins
Date: 2011-06-04 03:27:34 +0000 (Sat, 04 Jun 2011)
Log Message:
-----------
Revision: 29483
Author: nicholasbishop
Date: 11:55:06 PM, Tuesday, June 15, 2010
Message:
Brought back hiding parts of the mesh in sculpt mode in proper 2.5-style. (No more ugly reordering of mesh elements leading to mesh corruption!)
UI changes:
* Ctrl+Alt brings up a border select you can hide a rectangular area of the mesh with.
* Ctrl+Shift is the same, but hides the area outside of the rectangle.
* Clicking without dragging while holding either Ctrl+Alt or Ctrl+Shift will re-show hidden areas.
* Added these three operations to the Sculpt menu.
Hiding areas is done by rebuilding the PBVH and excluding primitives based on whether their AABB intersects the user-selected areas. Note that for multires meshes, the primitives are grids, not faces, so if you are bad and use multires on a plain cube, there are only 6*4 grids that can be hidden.
TODO:
* Applying multires temporarily shows hidden areas. Once you start sculpting they hide themselves again. Same for turning off display of multires modifier.
* Going to multires level zero also shows hidden areas improperly.
** jwilkins:
** renamed 'mask' panel to 'select'
** put hiding controls in 'select' panel instead of 'options'
** changed the button text to be more intuitive
Modified Paths:
--------------
branches/soc-2011-onion/release/scripts/startup/bl_ui/space_view3d_toolbar.py
branches/soc-2011-onion/source/blender/blenkernel/BKE_paint.h
branches/soc-2011-onion/source/blender/blenkernel/intern/cdderivedmesh.c
branches/soc-2011-onion/source/blender/blenkernel/intern/object.c
branches/soc-2011-onion/source/blender/blenkernel/intern/subsurf_ccg.c
branches/soc-2011-onion/source/blender/blenlib/BLI_pbvh.h
branches/soc-2011-onion/source/blender/blenlib/intern/pbvh.c
branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_ops.c
branches/soc-2011-onion/source/blender/editors/sculpt_paint/sculpt.c
branches/soc-2011-onion/source/blender/windowmanager/intern/wm_operators.c
Property Changed:
----------------
branches/soc-2011-onion/
Property changes on: branches/soc-2011-onion
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/soc-2010-jwilkins:28499-37009
/branches/soc-2010-nicolasbishop:28448-29455
/trunk/blender:36833-37054
+ /branches/soc-2010-jwilkins:28499-37009
/branches/soc-2010-nicolasbishop:28448-29455,29483
/trunk/blender:36833-37054
Modified: branches/soc-2011-onion/release/scripts/startup/bl_ui/space_view3d_toolbar.py
===================================================================
--- branches/soc-2011-onion/release/scripts/startup/bl_ui/space_view3d_toolbar.py 2011-06-04 03:07:56 UTC (rev 37158)
+++ branches/soc-2011-onion/release/scripts/startup/bl_ui/space_view3d_toolbar.py 2011-06-04 03:27:34 UTC (rev 37159)
@@ -703,7 +703,7 @@
class VIEW3D_PT_tools_masking(PaintPanel, bpy.types.Panel):
- bl_label = "Masking"
+ bl_label = "Select"
bl_default_closed = False
@classmethod
@@ -717,12 +717,21 @@
settings = self.paint_settings(context)
col = layout.column()
+ col.label("Masking:")
col.operator("paint.mask_set", text="Clear").mode = 'CLEAR'
col.operator("paint.mask_set", text="Fill").mode = 'FILL'
col.operator("paint.mask_set", text="Invert").mode = 'INVERT'
col.operator("paint.mask_set", text="Random").mode = 'RANDOM'
+ if context.sculpt_object:
+ layout.separator()
+ col = layout.column()
+ col.label("Hiding:")
+ col.operator("sculpt.area_hide", text="Show Hidden Areas").show_all = True
+ col.operator("sculpt.area_hide", text="Select Area to Show")
+ col.operator("sculpt.area_hide", text="Select Area to Hide").hide_inside = True
+
class VIEW3D_PT_tools_brush_texture(PaintPanel, bpy.types.Panel):
bl_label = "Texture"
bl_options = {'DEFAULT_CLOSED'}
Modified: branches/soc-2011-onion/source/blender/blenkernel/BKE_paint.h
===================================================================
--- branches/soc-2011-onion/source/blender/blenkernel/BKE_paint.h 2011-06-04 03:07:56 UTC (rev 37158)
+++ branches/soc-2011-onion/source/blender/blenkernel/BKE_paint.h 2011-06-04 03:27:34 UTC (rev 37159)
@@ -85,6 +85,9 @@
/* Partial redraw */
int partial_redraw;
+
+ /* Area hiding */
+ ListBase hidden_areas;
/* Used to cache the render of the active texture */
unsigned int texcache_side, *texcache, texcache_actual;
Modified: branches/soc-2011-onion/source/blender/blenkernel/intern/cdderivedmesh.c
===================================================================
--- branches/soc-2011-onion/source/blender/blenkernel/intern/cdderivedmesh.c 2011-06-04 03:07:56 UTC (rev 37158)
+++ branches/soc-2011-onion/source/blender/blenkernel/intern/cdderivedmesh.c 2011-06-04 03:27:34 UTC (rev 37159)
@@ -236,7 +236,8 @@
cddm->pbvh = BLI_pbvh_new();
cddm->pbvh_draw = can_pbvh_draw(ob, dm);
BLI_pbvh_build_mesh(cddm->pbvh, me->mface, me->mvert,
- &me->vdata, me->totface, me->totvert);
+ &me->vdata, me->totface, me->totvert,
+ &ob->sculpt->hidden_areas);
if(ss->modifiers_active && ob->derivedDeform) {
DerivedMesh *deformdm= ob->derivedDeform;
Modified: branches/soc-2011-onion/source/blender/blenkernel/intern/object.c
===================================================================
--- branches/soc-2011-onion/source/blender/blenkernel/intern/object.c 2011-06-04 03:07:56 UTC (rev 37158)
+++ branches/soc-2011-onion/source/blender/blenkernel/intern/object.c 2011-06-04 03:27:34 UTC (rev 37159)
@@ -241,6 +241,9 @@
if(ss->pbvh)
BLI_pbvh_free(ss->pbvh);
+
+ BLI_freelistN(&ss->hidden_areas);
+
if(dm && dm->getPBVH)
dm->getPBVH(NULL, dm); /* signal to clear */
Modified: branches/soc-2011-onion/source/blender/blenkernel/intern/subsurf_ccg.c
===================================================================
--- branches/soc-2011-onion/source/blender/blenkernel/intern/subsurf_ccg.c 2011-06-04 03:07:56 UTC (rev 37158)
+++ branches/soc-2011-onion/source/blender/blenkernel/intern/subsurf_ccg.c 2011-06-04 03:27:34 UTC (rev 37159)
@@ -2341,12 +2341,14 @@
ob->sculpt->pbvh= ccgdm->pbvh = BLI_pbvh_new();
BLI_pbvh_build_grids(ccgdm->pbvh, ccgdm->gridData, ccgdm->gridAdjacency,
- numGrids, gridSize, gridkey, (void**)ccgdm->gridFaces);
+ numGrids, gridSize, gridkey, (void**)ccgdm->gridFaces,
+ &ob->sculpt->hidden_areas);
} else if(ob->type == OB_MESH) {
Mesh *me= ob->data;
ob->sculpt->pbvh= ccgdm->pbvh = BLI_pbvh_new();
BLI_pbvh_build_mesh(ccgdm->pbvh, me->mface, me->mvert,
- &me->vdata, me->totface, me->totvert);
+ &me->vdata, me->totface, me->totvert,
+ &ob->sculpt->hidden_areas);
}
return ccgdm->pbvh;
Modified: branches/soc-2011-onion/source/blender/blenlib/BLI_pbvh.h
===================================================================
--- branches/soc-2011-onion/source/blender/blenlib/BLI_pbvh.h 2011-06-04 03:07:56 UTC (rev 37158)
+++ branches/soc-2011-onion/source/blender/blenlib/BLI_pbvh.h 2011-06-04 03:27:34 UTC (rev 37159)
@@ -1,3 +1,6 @@
+/**
+ * A BVH for high poly meshes.
+ *
/*
* $Id$
*
@@ -28,6 +31,7 @@
* \brief A BVH for high poly meshes.
*/
+struct BoundBox;
struct CustomData;
struct MFace;
struct MVert;
@@ -44,6 +48,12 @@
float (*co)[3];
} PBVHProxyNode;
+typedef struct PBVHHiddenArea {
+ struct PBVHHiddenArea *next, *prev;
+ float clip_planes[4][4];
+ int hide_inside;
+} HiddenArea;
+
/* Callbacks */
/* returns 1 if the search should continue from this node, 0 otherwise */
@@ -56,10 +66,12 @@
PBVH *BLI_pbvh_new(void);
void BLI_pbvh_build_mesh(PBVH *bvh, struct MFace *faces, struct MVert *verts,
- struct CustomData *vdata, int totface, int totvert);
+ struct CustomData *vdata, int totface, int totvert,
+ ListBase *hidden_areas);
void BLI_pbvh_build_grids(PBVH *bvh, struct DMGridData **grids,
struct DMGridAdjacency *gridadj, int totgrid,
- int gridsize, int gridkey, void **gridfaces);
+ int gridsize, int gridkey, void **gridfaces,
+ ListBase *hidden_areas);
void BLI_pbvh_free(PBVH *bvh);
/* Hierarchical Search in the BVH, two methods:
Modified: branches/soc-2011-onion/source/blender/blenlib/intern/pbvh.c
===================================================================
--- branches/soc-2011-onion/source/blender/blenlib/intern/pbvh.c 2011-06-04 03:07:56 UTC (rev 37158)
+++ branches/soc-2011-onion/source/blender/blenlib/intern/pbvh.c 2011-06-04 03:27:34 UTC (rev 37159)
@@ -28,6 +28,7 @@
#include "DNA_meshdata_types.h"
+#include "DNA_object_types.h"
#include "MEM_guardedalloc.h"
@@ -43,6 +44,8 @@
#include "GPU_buffers.h"
+static void pbvh_free_nodes(PBVH *bvh);
+
#define LEAF_LIMIT 10000
//#define PERFCNTRS
@@ -164,6 +167,37 @@
int stackspace;
} PBVHIter;
+
+
+/* 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.
+*/
+static int pbvh_planes_contain_AABB(float bb_min[3], float bb_max[3], float (*planes)[4])
+{
+ 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(dot_v3v3(planes[i], vmin) + planes[i][3] > 0)
+ return 0;
+ }
+
+ return 1;
+}
+
static void BB_reset(BB *bb)
{
bb->bmin[0] = bb->bmin[1] = bb->bmin[2] = FLT_MAX;
@@ -484,80 +518,147 @@
prim_bbc, end, offset + count - end);
}
-static void pbvh_build(PBVH *bvh, BB *cb, BBC *prim_bbc, int totprim)
+/* Returns 0 if the primitive should be hidden, 1 otherwise */
+static int test_prim_against_hidden_areas(BBC *prim_bbc, ListBase *hidden_areas)
{
- int i;
+ HiddenArea *area;
+ for(area = hidden_areas->first; area; area = area->next) {
+ int prim_inside_planes = pbvh_planes_contain_AABB(prim_bbc->bmin, prim_bbc->bmax, area->clip_planes);
+ if((prim_inside_planes && area->hide_inside) || (!prim_inside_planes && !area->hide_inside))
+ return 0;
+ }
+
+ return 1;
+}
+
+/* Initially, the root node contains all primitives in
+ their original order.
+
+ If we are clipping, exclude primitives outside the
+ clip planes from the primitive list
+*/
+static int pbvh_initialize_prim_indices(PBVH *bvh, BBC *prim_bbc, int totprim, ListBase *hidden_areas)
+{
+ int prim, index;
+ int *prim_indices;
+
+ prim_indices = MEM_callocN(sizeof(int) * totprim, "bvh prim indices");
+
+ for(prim= 0, index = 0; prim < totprim; ++prim) {
+ if(!hidden_areas || test_prim_against_hidden_areas(&prim_bbc[prim], hidden_areas)) {
+ prim_indices[index] = prim;
+ ++index;
+ }
+ }
+
+ if(index == prim) {
+ bvh->prim_indices = prim_indices;
+ return totprim;
+ }
+ else {
+ bvh->prim_indices = MEM_callocN(sizeof(int) * index, "bvh prim indices");
+ memcpy(bvh->prim_indices, prim_indices, sizeof(int) * index);
+ MEM_freeN(prim_indices);
+ return index;
+ }
+}
+
+static void pbvh_build(PBVH *bvh, BB *cb, BBC *prim_bbc, int totprim, ListBase *hidden_areas)
+{
+ int max_prim_index;
+
if(totprim != bvh->totprim) {
+ /* Initialize the nodes */
bvh->totprim = totprim;
- if(bvh->nodes) MEM_freeN(bvh->nodes);
+ if(bvh->nodes)
+ pbvh_free_nodes(bvh);
if(bvh->prim_indices) MEM_freeN(bvh->prim_indices);
- bvh->prim_indices = MEM_callocN(sizeof(int) * totprim,
- "bvh prim indices");
- for(i = 0; i < totprim; ++i)
- bvh->prim_indices[i] = i;
+
+ max_prim_index = pbvh_initialize_prim_indices(bvh, prim_bbc, totprim, hidden_areas);
+
bvh->totnode = 0;
- if(bvh->node_mem_count < 100) {
+ if(bvh->node_mem_count < 100)
bvh->node_mem_count = 100;
+
bvh->nodes = MEM_callocN(sizeof(PBVHNode) *
bvh->node_mem_count,
"bvh initial nodes");
}
- }
bvh->totnode = 1;
- build_sub(bvh, 0, cb, prim_bbc, 0, totprim);
+ build_sub(bvh, 0, cb, prim_bbc, 0, max_prim_index);
}
-/* Do a full rebuild with on Mesh data structure */
-void BLI_pbvh_build_mesh(PBVH *bvh, MFace *faces, MVert *verts, CustomData *vdata, int totface, int totvert)
+void pbvh_begin_build(PBVH *bvh, int totprim, ListBase *hidden_areas)
{
- BBC *prim_bbc = NULL;
+ int i, j;
+ int totgridelem;
+ BBC *prim_bbc;
BB cb;
- int i, j;
- bvh->faces = faces;
- bvh->verts = verts;
- bvh->vdata = vdata;
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list