[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [31470] branches/soc-2010-nicolasbishop/ source/blender/editors/sculpt_paint/paint_ptex.c: == Ptex ==
Nicholas Bishop
nicholasbishop at gmail.com
Fri Aug 20 04:59:01 CEST 2010
Revision: 31470
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=31470
Author: nicholasbishop
Date: 2010-08-20 04:58:58 +0200 (Fri, 20 Aug 2010)
Log Message:
-----------
== Ptex ==
Fixed grid artifacts when painting on subdivided mesh
Modified Paths:
--------------
branches/soc-2010-nicolasbishop/source/blender/editors/sculpt_paint/paint_ptex.c
Modified: branches/soc-2010-nicolasbishop/source/blender/editors/sculpt_paint/paint_ptex.c
===================================================================
--- branches/soc-2010-nicolasbishop/source/blender/editors/sculpt_paint/paint_ptex.c 2010-08-20 02:08:43 UTC (rev 31469)
+++ branches/soc-2010-nicolasbishop/source/blender/editors/sculpt_paint/paint_ptex.c 2010-08-20 02:58:58 UTC (rev 31470)
@@ -172,28 +172,37 @@
float v1[3], float v2[3], float v3[3], float v4[3])
{
- float dtop[3], dbot[3], yinterp, ustep, vstep;
- float co_bot[3], co_top[3];
+ float dtop[3], dbot[3], xoffset, yinterp, ustep, vstep;
+ float co_bot[3], co_top[3], start_top[3], start_bot[3];
int u, v, layersize;
layersize = pt->channels * ptex_data_size(pt->type);
+ /* start of top and bottom "rails" */
+ copy_v3_v3(start_top, v4);
+ copy_v3_v3(start_bot, v1);
+
+ /* direction of "rails" */
sub_v3_v3v3(dtop, v3, v4);
- sub_v3_v3v3(dbot, v2, v1);;
- ustep = 1;
- if(res[0] != 1)
- ustep /= (res[0] - 1);
+ sub_v3_v3v3(dbot, v2, v1);
+
+ /* offset to use center of texel rather than corner */
+ xoffset = 1.0f / (2 * res[0]);
+ yinterp = 1.0f / (2 * res[1]);
+ madd_v3_v3fl(start_top, dtop, xoffset);
+ madd_v3_v3fl(start_bot, dbot, xoffset);
+
+ ustep = 1.0f / res[0];
+ vstep = 1.0f / res[1];
+
+ /* precalculate interpolation along "rails" */
mul_v3_fl(dtop, ustep);
mul_v3_fl(dbot, ustep);
- vstep = 1;
- if(res[1] != 1)
- vstep /= (res[1] - 1);
+ for(v = 0; v < res[1]; ++v) {
+ copy_v3_v3(co_top, start_top);
+ copy_v3_v3(co_bot, start_bot);
- for(v = 0, yinterp = 0; v < res[1]; ++v) {
- copy_v3_v3(co_top, v4);
- copy_v3_v3(co_bot, v1);
-
for(u = 0; u < res[0]; ++u) {
float co[3];
More information about the Bf-blender-cvs
mailing list