[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [37190] branches/soc-2011-onion: Revision: 29888
Jason Wilkins
Jason.A.Wilkins at gmail.com
Sat Jun 4 21:45:48 CEST 2011
Revision: 37190
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=37190
Author: jwilkins
Date: 2011-06-04 19:45:47 +0000 (Sat, 04 Jun 2011)
Log Message:
-----------
Revision: 29888
Author: nicholasbishop
Date: 1:34:07 AM, Saturday, July 03, 2010
Message:
Added a new mask operator to create a mask from a texture.
* Moved get_texture value out of MOD_util and into BKE texture
* Added a new pbvh function similar to get_grids but for faces
* The new operator should work for ORCO and UV mapping
* UI is just a new menu item in the drop-down menu next to the texture slots list
* Also fixed a crash in the mask_set operator where sculpt's PBVH wasn't updated
** jwilkins:
** moved operator from menu to a button on texture panel, since the menu is not available in all texture contexts
** I think this button belongs on the select panel, but it doesn't work there. Need to figure out how to make it work in that context.
Modified Paths:
--------------
branches/soc-2011-onion/release/scripts/startup/bl_ui/properties_texture.py
branches/soc-2011-onion/release/scripts/startup/bl_ui/space_view3d_toolbar.py
branches/soc-2011-onion/source/blender/blenkernel/BKE_customdata.h
branches/soc-2011-onion/source/blender/blenkernel/BKE_texture.h
branches/soc-2011-onion/source/blender/blenkernel/intern/texture.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_intern.h
branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_mask.c
branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_ops.c
branches/soc-2011-onion/source/blender/modifiers/intern/MOD_util.c
branches/soc-2011-onion/source/blender/modifiers/intern/MOD_util.h
branches/soc-2011-onion/source/blender/modifiers/intern/MOD_wave.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-29796,29832,29860,29862,29878,29887
/trunk/blender:36833-37054
+ /branches/soc-2010-jwilkins:28499-37009
/branches/soc-2010-nicolasbishop:28448-29796,29832,29860,29862,29878,29887-29888
/trunk/blender:36833-37054
Modified: branches/soc-2011-onion/release/scripts/startup/bl_ui/properties_texture.py
===================================================================
--- branches/soc-2011-onion/release/scripts/startup/bl_ui/properties_texture.py 2011-06-04 18:20:13 UTC (rev 37189)
+++ branches/soc-2011-onion/release/scripts/startup/bl_ui/properties_texture.py 2011-06-04 19:45:47 UTC (rev 37190)
@@ -149,6 +149,8 @@
split.label(text="Type:")
split.prop(tex, "type", text="")
+ if context.sculpt_object:
+ layout.operator("paint.mask_from_texture")
class TEXTURE_PT_preview(TextureButtonsPanel, bpy.types.Panel):
bl_label = "Preview"
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 18:20:13 UTC (rev 37189)
+++ branches/soc-2011-onion/release/scripts/startup/bl_ui/space_view3d_toolbar.py 2011-06-04 19:45:47 UTC (rev 37190)
@@ -740,9 +740,10 @@
layout.separator()
col = layout.column(align=True)
col.label("Hide:")
- 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
+ col = layout.column(align=True)
+ col.operator("sculpt.area_hide", text="Show Hidden Areas").show_all = True
class VIEW3D_PT_tools_brush_texture(PaintPanel, bpy.types.Panel):
Modified: branches/soc-2011-onion/source/blender/blenkernel/BKE_customdata.h
===================================================================
--- branches/soc-2011-onion/source/blender/blenkernel/BKE_customdata.h 2011-06-04 18:20:13 UTC (rev 37189)
+++ branches/soc-2011-onion/source/blender/blenkernel/BKE_customdata.h 2011-06-04 19:45:47 UTC (rev 37190)
@@ -202,7 +202,7 @@
/* return the data from the first layer matching the parameters */
/* these all return NULL if no such layer is found */
-/* returns the data from the first layer matching type */
+/* returns the data from the active layer matching type */
void *CustomData_get_layer(const struct CustomData *data, int type);
/* returns the data from the nth layer matching type */
Modified: branches/soc-2011-onion/source/blender/blenkernel/BKE_texture.h
===================================================================
--- branches/soc-2011-onion/source/blender/blenkernel/BKE_texture.h 2011-06-04 18:20:13 UTC (rev 37189)
+++ branches/soc-2011-onion/source/blender/blenkernel/BKE_texture.h 2011-06-04 19:45:47 UTC (rev 37190)
@@ -53,6 +53,7 @@
struct PointDensity;
struct Tex;
struct TexMapping;
+struct TexResult;
struct VoxelData;
struct World;
@@ -124,6 +125,8 @@
int BKE_texture_dependsOnTime(const struct Tex *texture);
+void get_texture_value(struct Tex *texture, float *tex_co, struct TexResult *texres);
+
#ifdef __cplusplus
}
#endif
Modified: branches/soc-2011-onion/source/blender/blenkernel/intern/texture.c
===================================================================
--- branches/soc-2011-onion/source/blender/blenkernel/intern/texture.c 2011-06-04 18:20:13 UTC (rev 37189)
+++ branches/soc-2011-onion/source/blender/blenkernel/intern/texture.c 2011-06-04 19:45:47 UTC (rev 37190)
@@ -74,6 +74,9 @@
#include "BKE_animsys.h"
#include "BKE_colortools.h"
+#include "RE_shader_ext.h"
+
+
/* ------------------------------------------------------------------------- */
/* All support for plugin textures: */
@@ -1468,3 +1471,20 @@
}
/* ------------------------------------------------------------------------- */
+
+void get_texture_value(Tex *texture, float *tex_co, TexResult *texres)
+{
+ int result_type;
+
+ result_type = multitex_ext(texture, tex_co, NULL, NULL, 0, texres);
+
+ /* if the texture gave an RGB value, we assume it didn't give a valid
+ * intensity, so calculate one (formula from do_material_tex).
+ * if the texture didn't give an RGB value, copy the intensity across
+ */
+ if(result_type & TEX_RGB)
+ texres->tin = (0.35f * texres->tr + 0.45f * texres->tg
+ + 0.2f * texres->tb);
+ else
+ texres->tr = texres->tg = texres->tb = texres->tin;
+}
Modified: branches/soc-2011-onion/source/blender/blenlib/BLI_pbvh.h
===================================================================
--- branches/soc-2011-onion/source/blender/blenlib/BLI_pbvh.h 2011-06-04 18:20:13 UTC (rev 37189)
+++ branches/soc-2011-onion/source/blender/blenlib/BLI_pbvh.h 2011-06-04 19:45:47 UTC (rev 37190)
@@ -134,6 +134,8 @@
void BLI_pbvh_node_mark_update(PBVHNode *node);
void BLI_pbvh_node_set_flags(PBVHNode *node, void *data);
+void BLI_pbvh_node_get_faces(PBVH *bvh, PBVHNode *node,
+ int **face_indices, int *totnode);
void BLI_pbvh_node_get_grids(PBVH *bvh, PBVHNode *node,
int **grid_indices, int *totgrid, int *maxgrid, int *gridsize,
struct DMGridData ***griddata, struct DMGridAdjacency **gridadj, struct GridKey **gridkey);
Modified: branches/soc-2011-onion/source/blender/blenlib/intern/pbvh.c
===================================================================
--- branches/soc-2011-onion/source/blender/blenlib/intern/pbvh.c 2011-06-04 18:20:13 UTC (rev 37189)
+++ branches/soc-2011-onion/source/blender/blenlib/intern/pbvh.c 2011-06-04 19:45:47 UTC (rev 37190)
@@ -1323,6 +1323,19 @@
}
}
+void BLI_pbvh_node_get_faces(PBVH *bvh, PBVHNode *node,
+ int **face_indices, int *totnode)
+{
+ if(bvh->grids) {
+ if(face_indices) *face_indices= NULL;
+ if(totnode) *totnode= 0;
+ }
+ else {
+ if(face_indices) *face_indices= node->prim_indices;
+ if(totnode) *totnode= node->totprim;
+ }
+}
+
void BLI_pbvh_node_get_grids(PBVH *bvh, PBVHNode *node, int **grid_indices, int *totgrid, int *maxgrid, int *gridsize, DMGridData ***griddata, DMGridAdjacency **gridadj, GridKey **gridkey)
{
if(bvh->grids) {
Modified: branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_intern.h
===================================================================
--- branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_intern.h 2011-06-04 18:20:13 UTC (rev 37189)
+++ branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_intern.h 2011-06-04 19:45:47 UTC (rev 37190)
@@ -146,7 +146,6 @@
void PAINT_OT_mask_layer_add(struct wmOperatorType *ot);
void PAINT_OT_mask_layer_remove(struct wmOperatorType *ot);
-/* For now this is just temporary stuff to test masking */
typedef enum {
MASKING_CLEAR,
MASKING_FILL,
@@ -154,6 +153,7 @@
MASKING_RANDOM,
} MaskSetMode;
void PAINT_OT_mask_set(struct wmOperatorType *ot);
+void PAINT_OT_mask_from_texture(struct wmOperatorType *ot);
#endif /* ED_PAINT_INTERN_H */
Modified: branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_mask.c
===================================================================
--- branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_mask.c 2011-06-04 18:20:13 UTC (rev 37189)
+++ branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_mask.c 2011-06-04 19:45:47 UTC (rev 37190)
@@ -7,6 +7,7 @@
#include "DNA_mesh_types.h"
#include "DNA_meshdata_types.h"
#include "DNA_object_types.h"
+#include "DNA_material_types.h"
#include "RNA_access.h"
#include "RNA_define.h"
@@ -22,8 +23,10 @@
#include "BKE_mesh.h"
#include "BKE_multires.h"
#include "BKE_paint.h"
+#include "BKE_texture.h"
#include "BLI_listbase.h"
+#include "BLI_math.h"
#include "BLI_pbvh.h"
#include "BLI_utildefines.h"
@@ -32,6 +35,261 @@
#include "paint_intern.h"
#include "sculpt_intern.h"
+#include "RE_render_ext.h"
+#include "RE_shader_ext.h"
+
+/* for redraw, just need to update the pbvh's vbo buffers */
+static void paintmask_redraw(bContext *C)
+{
+ Object *ob = CTX_data_active_object(C);
+
+ paint_refresh_mask_display(ob);
+
+ WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob);
+}
+
+/* For now masking requires sculpt mode */
+static int mask_poll(bContext *C)
+{
+ Object *ob = CTX_data_active_object(C);
+
+ return ob && get_mesh(ob) && ob->sculpt;
+}
+
+static int mask_active_poll(bContext *C)
+{
+ Object *ob = CTX_data_active_object(C);
+
+ if(mask_poll(C)) {
+ Mesh *me = get_mesh(ob);
+ return CustomData_get_active_layer_index(&me->vdata, CD_PAINTMASK) != -1;
+ }
+
+ return 0;
+}
+
+static float get_tex_mask_strength(MTex *tex_slot, float *uv, float vco[3])
+{
+ float texvec[3] = {0, 0, 0};
+ TexResult texres;
+ int mapping = tex_slot->texco;
+
+ if(mapping == TEXCO_UV && !uv)
+ mapping = TEXCO_ORCO;
+
+ switch(tex_slot->texco) {
+ case TEXCO_UV:
+ texvec[0] = uv[0] * 2 - 1;
+ texvec[1] = uv[1] * 2 - 1;
+ break;
+ default:
+ copy_v3_v3(texvec, vco);
+ }
+
+ memset(&texres, 0, sizeof(TexResult));
+ get_texture_value(tex_slot->tex, texvec, &texres);
+
+ return texres.tin;
+}
+
+/* Set the value of a single mask element from either a UV or a coord */
+#define SET_MASK(elem, uv) \
+ GRIDELEM_MASK(elem, gridkey)[active] = \
+ get_tex_mask_strength(tex_slot, uv, \
+ GRIDELEM_CO(elem, gridkey)) \
+
+/* Fill active mask layer of entire grid from either MTFaces or coords */
+static void mask_grid_from_tex(DMGridData *grid, int gridsize,
+ GridKey *gridkey, MTFace *mtface,
+ MTex *tex_slot, int active)
+{
+ int x, y, boundary;
+
+ boundary = gridsize - 2;
+
+ for(y = 0; y <= boundary; ++y) {
+ for(x = 0; x <= boundary; ++x) {
+ SET_MASK(GRIDELEM_AT(grid, y*gridsize+x, gridkey),
+ mtface ? mtface->uv[0] : NULL);
+
+ /* Do the edge of the grid separately because the UV
+ grid is one element smaller on each side compared
+ to the vert-data grid */
+ if(x == boundary && y == boundary) {
+ SET_MASK(GRIDELEM_AT(grid, (y+1)*gridsize+x+1, gridkey),
+ mtface ? mtface->uv[2] : NULL);
+ }
+ if(x == boundary) {
+ SET_MASK(GRIDELEM_AT(grid, y*gridsize+x+1, gridkey),
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list