[Bf-committers] [Bf-blender-cvs] SVN commit: /data/svn/bf-blender [31490] branches/soc-2010-nicolasbishop/ source/blender: == Ptex ==

Nicholas Bishop nicholasbishop at gmail.com
Sat Aug 21 05:46:07 CEST 2010


Originally I was using face select mode for ptex, but that's no longer
the case; I added another mode flag for ptex editing. I didn't revert
all the changes to face selection mode though, so perhaps some things
are still broken?

Also, I have "taken over" the face select button for ptex resolution
editing, so the old face selection mode isn't currently exposed in my
branch. Ideally, the ptex editing mode should grow to support face
hiding and such (unlike the older face select, the new mode uses the
PBVH for selection, so it doesn't have any of that nasty backbuf
selection stuff.)

Is there anything other than masking and hiding that face select mode
can do that the ptex edit mode can't?

Thanks,
-Nicholas

On Fri, Aug 20, 2010 at 11:36 PM, Daniel Salazar - 3Developer.com
<zanqdo at gmail.com> wrote:
> Hi nick, I don know your plans about this but face select mode is used
> to mask and/or hide faces on paint modes and his functionality is
> colliding with your implementation. Care to shed some light into this?
>
> cheers
>
> Daniel Salazar
> www.3developer.com
>
>
>
> On Fri, Aug 20, 2010 at 9:09 PM, Nicholas Bishop
> <nicholasbishop at gmail.com> wrote:
>> Revision: 31490
>>          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=31490
>> Author:   nicholasbishop
>> Date:     2010-08-21 05:09:20 +0200 (Sat, 21 Aug 2010)
>>
>> Log Message:
>> -----------
>> == Ptex ==
>>
>> Resolution editing works now with VBO enabled
>>
>> Modified Paths:
>> --------------
>>    branches/soc-2010-nicolasbishop/source/blender/editors/sculpt_paint/paint_ptex.c
>>    branches/soc-2010-nicolasbishop/source/blender/gpu/intern/gpu_buffers.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-21 00:31:08 UTC (rev 31489)
>> +++ branches/soc-2010-nicolasbishop/source/blender/editors/sculpt_paint/paint_ptex.c    2010-08-21 03:09:20 UTC (rev 31490)
>> @@ -872,6 +872,31 @@
>>        }
>>  }
>>
>> +static void ptex_redraw_selected(PBVHNode *node, void *data)
>> +{
>> +       PBVH *pbvh = data;
>> +       MPtex *mptex;
>> +       GridToFace *grid_face_map;
>> +       CustomData *fdata;
>> +       int totgrid, *grid_indices, i;
>> +
>> +       BLI_pbvh_get_customdata(pbvh, NULL, &fdata);
>> +       mptex = CustomData_get_layer(fdata, CD_MPTEX);
>> +       grid_face_map = BLI_pbvh_get_grid_face_map(pbvh);
>> +       BLI_pbvh_node_get_grids(pbvh, node,
>> +                               &grid_indices, &totgrid, NULL, NULL,
>> +                               NULL, NULL, NULL);
>> +
>> +       for(i = 0; i < totgrid; ++i) {
>> +               GridToFace *gtf = &grid_face_map[grid_indices[i]];
>> +               if(mptex[gtf->face].subfaces[gtf->offset].flag & MPTEX_SUBFACE_SELECTED) {
>> +                       BLI_pbvh_node_set_flags(node,
>> +                                               SET_INT_IN_POINTER(PBVH_UpdateColorBuffers|
>> +                                                                  PBVH_UpdateRedraw));
>> +               }
>> +       }
>> +}
>> +
>>  static int ptex_face_resolution_set_exec(bContext *C, wmOperator *op)
>>  {
>>        ToolSettings *ts = CTX_data_tool_settings(C);
>> @@ -891,6 +916,8 @@
>>                }
>>        }
>>
>> +       BLI_pbvh_search_callback(ob->paint->pbvh, NULL, NULL, ptex_redraw_selected, ob->paint->pbvh);
>> +
>>        WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob);
>>
>>        return OPERATOR_FINISHED;
>>
>> Modified: branches/soc-2010-nicolasbishop/source/blender/gpu/intern/gpu_buffers.c
>> ===================================================================
>> --- branches/soc-2010-nicolasbishop/source/blender/gpu/intern/gpu_buffers.c     2010-08-21 00:31:08 UTC (rev 31489)
>> +++ branches/soc-2010-nicolasbishop/source/blender/gpu/intern/gpu_buffers.c     2010-08-21 03:09:20 UTC (rev 31490)
>> @@ -742,15 +742,22 @@
>>
>>  void GPU_update_grid_uv_buffer(GPU_Buffers *buffers, PBVH *pbvh, PBVHNode *node, DMDrawFlags flags)
>>  {
>> +       CustomData *fdata;
>> +       GridToFace *grid_face_map;
>> +       MPtex *mptex;
>>        float (*uv_data)[2];
>>        int *grid_indices, totgrid, gridsize, totvert;
>>
>>        if(!buffers->vert_buf)
>>                return;
>>
>> +       BLI_pbvh_get_customdata(pbvh, NULL, &fdata);
>> +       mptex = CustomData_get_layer(fdata, CD_MPTEX);
>> +       grid_face_map = BLI_pbvh_get_grid_face_map(pbvh);
>>        BLI_pbvh_node_get_grids(pbvh, node,
>>                                &grid_indices, &totgrid, NULL, &gridsize,
>>                                NULL, NULL, NULL);
>> +
>>        /* for now, pbvh is required to give one node per subface in ptex mode */
>>        assert(totgrid == 1);
>>
>> @@ -758,11 +765,31 @@
>>        uv_data= map_uv_buffer(buffers, (flags & DM_DRAW_PTEX), totvert);
>>
>>        if(uv_data) {
>> -               int u, v;
>> -               for(v = 0; v < gridsize; ++v) {
>> -                       for(u = 0; u < gridsize; ++u, ++uv_data) {
>> -                               uv_data[0][0] = u / (gridsize - 1.0f);
>> -                               uv_data[0][1] = v / (gridsize - 1.0f);
>> +               GridToFace *gtf = &grid_face_map[grid_indices[0]];
>> +               MPtex *pt = &mptex[gtf->face];
>> +               MPtexSubface *subface = &pt->subfaces[gtf->offset];
>> +               float u, v, ustep, vstep, vstart = 0;
>> +               int x, y;
>> +
>> +               if(flags & DM_DRAW_PTEX_TEXELS) {
>> +                       ustep = subface->res[0] >> 1;
>> +                       vstep = subface->res[1] >> 1;
>> +                       /* make quad texel pattern appear uniform across all four subfaces */
>> +                       if(gtf->offset % 2)
>> +                               vstart = 0.5;
>> +               }
>> +               else {
>> +                       ustep = 1;
>> +                       vstep = 1;
>> +               }
>> +
>> +               ustep /= gridsize - 1.0f;
>> +               vstep /= gridsize - 1.0f;
>> +
>> +               for(y = 0, v = vstart; y < gridsize; ++y, v += vstep) {
>> +                       for(x = 0, u = 0; x < gridsize; ++x, u += ustep, ++uv_data) {
>> +                               uv_data[0][0] = u;
>> +                               uv_data[0][1] = v;
>>                        }
>>                }
>>
>> @@ -1126,7 +1153,7 @@
>>
>>                        if(ptex_edit) {
>>                                if(subface->flag & MPTEX_SUBFACE_SELECTED)
>> -                                       glColor3ub(255, 255, 255);
>> +                                       glColor3ub(255, 255, 255);
>>                                else
>>                                        glColor3ub(128, 128, 128);
>>                        }
>> @@ -1224,7 +1251,7 @@
>>        glShadeModel((flags & DM_DRAW_FULLY_SMOOTH) ? GL_SMOOTH: GL_FLAT);
>>
>>        if(buffers->vert_buf && buffers->index_buf) {
>> -               GLboolean colmat;
>> +               GLboolean use_colmat, colmat;
>>
>>                glEnableClientState(GL_VERTEX_ARRAY);
>>                glEnableClientState(GL_NORMAL_ARRAY);
>> @@ -1236,7 +1263,8 @@
>>                glBindBufferARB(GL_ARRAY_BUFFER_ARB, buffers->vert_buf);
>>                glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, buffers->index_buf);
>>
>> -               if(buffers->color_buf) {
>> +               use_colmat = buffers->color_buf || (flags & DM_DRAW_PTEX_TEXELS);
>> +               if(use_colmat) {
>>                        glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE);
>>                        glGetBooleanv(GL_COLOR_MATERIAL, &colmat);
>>                        glEnable(GL_COLOR_MATERIAL);
>> @@ -1251,7 +1279,33 @@
>>                        }
>>                        if(buffers->uv_buf) {
>>                                glEnable(GL_TEXTURE_2D);
>> -                               glBindTexture(GL_TEXTURE_2D, buffers->ptex[0]);
>> +                               if(flags & DM_DRAW_PTEX_TEXELS) {
>> +                                       int *grid_indices;
>> +                                       CustomData *fdata;
>> +                                       GridToFace *gtf;
>> +                                       MPtex *mptex, *pt;
>> +                                       MPtexSubface *subface;
>> +                                       GridToFace *grid_face_map;
>> +
>> +                                       BLI_pbvh_get_customdata(pbvh, NULL, &fdata);
>> +                                       mptex = CustomData_get_layer(fdata, CD_MPTEX);
>> +                                       grid_face_map = BLI_pbvh_get_grid_face_map(pbvh);
>> +                                       BLI_pbvh_node_get_grids(pbvh, node,
>> +                                                               &grid_indices, NULL, NULL, NULL,
>> +                                                               NULL, NULL, NULL);
>> +
>> +                                       gtf = &grid_face_map[grid_indices[0]];
>> +                                       pt = &mptex[gtf->face];
>> +                                       subface = &pt->subfaces[gtf->offset];
>> +
>> +                                       gpu_bind_ptex_pattern();
>> +                                       if(subface->flag & MPTEX_SUBFACE_SELECTED)
>> +                                               glColor3ub(255, 255, 255);
>> +                                       else
>> +                                               glColor3ub(128, 128, 128);
>> +                               }
>> +                               else
>> +                                       glBindTexture(GL_TEXTURE_2D, buffers->ptex[0]);
>>                                glBindBufferARB(GL_ARRAY_BUFFER_ARB, buffers->uv_buf);
>>                                glTexCoordPointer(2, GL_FLOAT, 0, (void*)0);
>>                        }
>> @@ -1273,7 +1327,7 @@
>>                        glDrawElements(GL_TRIANGLES, buffers->tot_tri * 3, buffers->index_type, 0);
>>                }
>>
>> -               if(buffers->color_buf && !colmat)
>> +               if(use_colmat && !colmat)
>>                        glDisable(GL_COLOR_MATERIAL);
>>
>>                glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0);
>>
>>
>> _______________________________________________
>> Bf-blender-cvs mailing list
>> Bf-blender-cvs at blender.org
>> http://lists.blender.org/mailman/listinfo/bf-blender-cvs
>>
> _______________________________________________
> Bf-committers mailing list
> Bf-committers at blender.org
> http://lists.blender.org/mailman/listinfo/bf-committers
>


More information about the Bf-committers mailing list