[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [37379] branches/soc-2011-onion: Revision: 30707
Jason Wilkins
Jason.A.Wilkins at gmail.com
Fri Jun 10 21:31:50 CEST 2011
Revision: 37379
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=37379
Author: jwilkins
Date: 2011-06-10 19:31:49 +0000 (Fri, 10 Jun 2011)
Log Message:
-----------
Revision: 30707
Author: nicholasbishop
Date: 12:01:55 AM, Sunday, July 25, 2010
Message:
== VPaint ==
Enabled textures for vpaint brushes. Not all of the texture options work yet.
**jwilkins:
**this was a troublesome merge, not sure what to fix now and what to leave til later
**I erred on the side of keeping things that worked before still working
**fixed bug where vpaint was ignoring unified size setting
**merged in wrap mode texture code as well, doesn't work in vpaint_blend
**kept some of the old code around for reference
**ED_view3d_project_float does not seem to do the same thing as projectf
**so, not ready to replace projectf and with ED_view3d_project_float and bgMats with just project_mat
Modified Paths:
--------------
branches/soc-2011-onion/release/scripts/startup/bl_ui/space_view3d_toolbar.py
branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_intern.h
branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_stroke.c
branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_utils.c
branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_vertex.c
branches/soc-2011-onion/source/blender/editors/sculpt_paint/sculpt.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-30676,30692-30693,30696,30699-30702,30742
/trunk/blender:36833-37206
+ /branches/soc-2010-jwilkins:28499-37009
/branches/soc-2010-nicolasbishop:28448-30676,30692-30693,30696,30699-30702,30707,30742
/trunk/blender:36833-37206
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-10 19:03:43 UTC (rev 37378)
+++ branches/soc-2011-onion/release/scripts/startup/bl_ui/space_view3d_toolbar.py 2011-06-10 19:31:49 UTC (rev 37379)
@@ -754,6 +754,7 @@
def poll(cls, context):
settings = cls.paint_settings(context)
return (settings and settings.brush and (context.sculpt_object or
+ context.vertex_paint_object or
context.image_paint_object))
def draw(self, context):
@@ -769,7 +770,7 @@
if brush.use_paint_image:
col.prop(brush, "use_fixed_texture")
- if context.sculpt_object:
+ if context.sculpt_object or context.vertex_paint_object:
#XXX duplicated from properties_texture.py
col.separator()
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-10 19:03:43 UTC (rev 37378)
+++ branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_intern.h 2011-06-10 19:31:49 UTC (rev 37379)
@@ -38,8 +38,9 @@
struct ARegion;
struct bContext;
+struct Brush;
+struct Scene;
struct bglMats;
-struct Brush;
struct ListBase;
struct Mesh;
struct Object;
@@ -70,6 +71,8 @@
int paint_stroke_modal(struct bContext *C, struct wmOperator *op, struct wmEvent *event);
int paint_stroke_exec(struct bContext *C, struct wmOperator *op);
struct ViewContext *paint_stroke_view_context(struct PaintStroke *stroke);
+void paint_stroke_projection_mat(struct PaintStroke *stroke, float (**pmat)[4]);
+void paint_stroke_bgl_mats(PaintStroke *stroke, struct bglMats **mats);
void *paint_stroke_mode_data(struct PaintStroke *stroke);
void paint_stroke_set_mode_data(struct PaintStroke *stroke, void *mode_data);
@@ -144,6 +147,12 @@
struct MultiresModifierData *paint_multires_active(struct Scene *scene, struct Object *ob);
+float brush_tex_strength(struct ViewContext *vc,
+ float pmat[4][4], float symm_brush_local_mat[4][4], int mirror_symmetry_pass, struct Brush *br,
+ float co[3], float mask, const float len,
+ float pixel_radius, float radius3d,
+ float special_rotation, float tex_mouse[2], struct bglMats* mats);
+
/* stroke operator */
typedef enum BrushStrokeMode {
BRUSH_STROKE_NORMAL,
Modified: branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_stroke.c
===================================================================
--- branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_stroke.c 2011-06-10 19:03:43 UTC (rev 37378)
+++ branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_stroke.c 2011-06-10 19:31:49 UTC (rev 37379)
@@ -75,6 +75,7 @@
/* Cached values */
ViewContext vc;
+ float project_mat[4][4];
bglMats mats;
Brush *brush;
@@ -1552,6 +1553,7 @@
/* see if tablet affects event */
pressure = event_tablet_data(event, &pen_flip);
+ ED_view3d_ob_project_mat_get(stroke->vc.rv3d, stroke->vc.obact, stroke->project_mat);
/* TODO: as sculpt and other paint modes are unified, this
separation will go away */
@@ -1841,6 +1843,16 @@
return &stroke->vc;
}
+void paint_stroke_projection_mat(PaintStroke *stroke, float (**pmat)[4])
+{
+ *pmat = stroke->project_mat;
+}
+
+void paint_stroke_bgl_mats(PaintStroke *stroke, bglMats **mats)
+{
+ *mats = &(stroke->mats);
+}
+
void *paint_stroke_mode_data(struct PaintStroke *stroke)
{
return stroke->mode_data;
Modified: branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_utils.c
===================================================================
--- branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_utils.c 2011-06-10 19:03:43 UTC (rev 37378)
+++ branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_utils.c 2011-06-10 19:31:49 UTC (rev 37379)
@@ -41,6 +41,9 @@
#include "WM_api.h"
#include "WM_types.h"
+#include "RE_render_ext.h"
+#include "RE_shader_ext.h"
+
#include "paint_intern.h"
/* convert a point in model coordinates to 2D screen coordinates */
@@ -88,7 +91,7 @@
co[2] = 0;
memset(&texres, 0, sizeof(TexResult));
- hasrgb = multitex_ext(br->mtex.tex, co, NULL, NULL, 0, &texres);
+ hasrgb = multitex_ext(br->mtex.tex, co, NULL, NULL, 1, &texres);
if (hasrgb & TEX_RGB)
texres.tin = (0.35f*texres.tr + 0.45f*texres.tg + 0.2f*texres.tb)*texres.ta;
@@ -579,3 +582,144 @@
{
return (ob && ob->paint && ob->paint->last_stroke_valid) ? ob->paint->last_stroke : NULL;
}
+
+/* return a multiplier for brush strength at a coordinate,
+ incorporating texture, curve control, and masking
+
+ TODO: pulled almost directly from sculpt, still needs
+ to be prettied up
+*/
+float brush_tex_strength(
+ ViewContext *vc,
+ float pmat[4][4],
+ float symm_brush_local_mat[4][4],
+ int mirror_symmetry_pass,
+ Brush *br,
+ float co[3],
+ float mask,
+ const float len,
+ float pixel_radius,
+ float radius3d,
+ float special_rotation,
+ float tex_mouse[2],
+ bglMats* mats)
+{
+ /* rotation direction is flipped in different symmetrical passes */
+ static const int rotation_flip[8] = { 1, -1, -1, 1, -1, 1, 1, -1 };
+
+ MTex *mtex = &br->mtex;
+ float avg= 1;
+
+ if(!mtex->tex) {
+ avg= 1;
+ }
+ else if(mtex->brush_map_mode == MTEX_MAP_MODE_3D) {
+ float jnk;
+
+ /* Get strength by feeding the vertex
+ location directly into a texture */
+ externtex(mtex, co, &avg,
+ &jnk, &jnk, &jnk, &jnk, 0); // XXX: minor, is last argument a pointer?
+ }
+ else if(ELEM(mtex->brush_map_mode, MTEX_MAP_MODE_FIXED, MTEX_MAP_MODE_TILED)) {
+ float rotation = -mtex->rot;
+ float x, y, point_2d[2];
+ float radius;
+
+ projectf(mats, co, point_2d); // XXX: due to texture mapping not working
+ //ED_view3d_project_float(vc->ar, co, point_2d, pmat);
+
+ /* if fixed mode, keep coordinates relative to mouse */
+ if(mtex->brush_map_mode == MTEX_MAP_MODE_FIXED) {
+ rotation += special_rotation;
+
+ point_2d[0] -= tex_mouse[0];
+ point_2d[1] -= tex_mouse[1];
+
+ radius = pixel_radius; // use pressure adjusted size for fixed mode
+
+ x = point_2d[0];
+ y = point_2d[1];
+ }
+ else /* else (mtex->brush_map_mode == MTEX_MAP_MODE_TILED),
+ leave the coordinates relative to the screen */
+ {
+ radius = brush_size(br); // use unadjusted size for tiled mode
+
+ x = point_2d[0] - vc->ar->winrct.xmin;
+ y = point_2d[1] - vc->ar->winrct.ymin;
+ }
+
+ x /= vc->ar->winx;
+ y /= vc->ar->winy;
+
+ if (mtex->brush_map_mode == MTEX_MAP_MODE_TILED) {
+ x -= 0.5f;
+ y -= 0.5f;
+ }
+
+ x *= vc->ar->winx / radius;
+ y *= vc->ar->winy / radius;
+
+ /* it is probably worth optimizing for those cases where
+ the texture is not rotated by skipping the calls to
+ atan2, sqrtf, sin, and cos. */
+ if (rotation > 0.001 || rotation < -0.001) {
+ const float angle = atan2(y, x) + rotation;
+ const float flen = sqrtf(x*x + y*y);
+
+ x = flen * cos(angle);
+ y = flen * sin(angle);
+ }
+
+ x *= br->mtex.size[0];
+ y *= br->mtex.size[1];
+
+ x += br->mtex.ofs[0];
+ y += br->mtex.ofs[1];
+
+ avg = paint_get_tex_pixel(br, x, y);
+ }
+ // XXX: redunancy here can be refactored once this has been debugged
+ else /* mtex->brush_map_mode == MTEX_MAP_MODE_WRAP */{
+ float rotation = -mtex->rot;
+ float x, y, point_2d[3];
+
+ copy_v3_v3(point_2d, co);
+ mul_m4_v3(symm_brush_local_mat, point_2d);
+
+ x = point_2d[0];
+ y = point_2d[1];
+
+ if (br->flag & BRUSH_RANDOM_ROTATION)
+ rotation += special_rotation;
+
+ /* it is probably worth optimizing for those cases where
+ the texture is not rotated by skipping the calls to
+ atan2, sqrtf, sin, and cos. */
+
+ if (rotation > 0.001 || rotation < -0.001) {
+ const float angle = (atan2(y, x) + rotation) * rotation_flip[mirror_symmetry_pass];
+ const float flen = sqrtf(x*x + y*y);
+
+ x = flen * cos(angle);
+ y = flen * sin(angle);
+ }
+
+ x *= br->mtex.size[0];
+ y *= br->mtex.size[1];
+
+ x += br->mtex.ofs[0];
+ y += br->mtex.ofs[1];
+
+ avg = paint_get_tex_pixel(br, x, y);
+ }
+
+ avg += br->texture_sample_bias;
+
+ avg *= brush_curve_strength(br, len, radius3d); /* Falloff curve */
+
+ avg *= 1 - mask;
+
+ return avg;
+}
Modified: branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_vertex.c
===================================================================
--- branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_vertex.c 2011-06-10 19:03:43 UTC (rev 37378)
+++ branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_vertex.c 2011-06-10 19:31:49 UTC (rev 37379)
@@ -1659,10 +1659,41 @@
}
}
+static float tex_strength(Brush *brush, PaintStroke *stroke,
+ float co[3], float mask, float len,
+ float radius3d)
+{
+ ViewContext *vc = paint_stroke_view_context(stroke);
+ float (*pmat)[4];
+ float tex_mouse[2] = {0,0}; /* TODO */
+ float symm_brush_local_mat[4][4]= MAT4_UNITY; /* TODO */
+ int mirror_symmetry_pass= 0; /* TODO */
+ struct bglMats* mats;
+
+ paint_stroke_projection_mat(stroke, &pmat);
+ paint_stroke_bgl_mats(stroke, &mats); // XXX: due to texture mapping not working
+
+ return
+ brush_tex_strength(
+ vc,
+ pmat,
+ symm_brush_local_mat,
+ mirror_symmetry_pass,
+ brush,
+ co,
+ 0,
+ len,
+ brush->size,
+ radius3d,
+ 0,
+ tex_mouse,
+ mats);
+}
+
/* apply paint at specified coordinate
returns 1 if paint was applied, 0 otherwise */
-static int vpaint_paint_coord(VPaint *vp, VPaintData *vpd, float co[3],
- float col[4], float orig_col[4],
+static int vpaint_paint_coord(VPaint *vp, PaintStroke *stroke,
+ float co[3], float col[4],
float center[3], float radius,
float radius_squared)
{
@@ -1675,8 +1706,7 @@
dist = sqrtf(dist_squared);
strength = brush->alpha *
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list