bugGNU Octave - Bugs: bug #55014, Property VertexNormals not updated...

 
 

bug #55014: Property VertexNormals not updated when Vertices are

Submitter:  Guillaume <gyom>
Submitted:  Mon 12 Nov 2018 01:44:36 PM UTC
   
 
Category:  Plotting with OpenGL Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Incorrect Result
Status:  Fixed Assigned to:  None
Originator Name:  Guillaume Open/Closed:  * Closed
Release:  * dev Operating System:  * Any
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Mon 19 Nov 2018 12:29:54 PM UTC, comment #4: 

Thanks for testing.

Closing as fixed.

Markus Mützel <mmuetzel>
Group administrator
Mon 19 Nov 2018 10:28:30 AM UTC, comment #3: 

Thank you Markus, it works perfectly now!

Guillaume <gyom>
Fri 16 Nov 2018 07:11:44 PM UTC, comment #2: 

I pushed a patch here that fixes the issue for me:
http://hg.savannah.gnu.org/hgweb/octave/rev/fda3bc89c528

The results for the example script with that changeset:

ans =

0.196148 0.972595 -0.124835
0.210776 0.951005 -0.226191
0.052961 0.802618 0.594137

ans =

0.197744 0.972390 -0.123917
0.174780 0.959882 -0.219266
0.054484 0.801638 0.595322

ans =

0.199261 0.972198 -0.122986
0.263109 0.937257 -0.228742
0.055405 0.800945 0.596169


Marking as ready for test.

Markus Mützel <mmuetzel>
Group administrator
Tue 13 Nov 2018 12:14:34 AM UTC, comment #1: 

I'm really sure this is just because there isn't a listener on the Vertices property which fires when the Vertices are changed and calls the function to update the VertexNormals.

This can be mimicked with addlistener(), but it probably should be coded in C++.  For example, if you update xdata on a patch, the Face and Vertices properties are automatically changed.

Rik <rik5>
Group administrator
Mon 12 Nov 2018 01:44:36 PM UTC, original submission:  

If you download the Stanford Bunny mesh and run the following:


% http://www-static.cc.gatech.edu/data_files/large_models/bunny.ply.gz
M = struct('vertices',[],'faces',[]);
fid = fopen('bunny.ply','rt');
while true
    l = fgetl(fid);
    if strcmp(l,'end_header'), break; end
end
nv = 35947; nf = 69451;
M.vertices = fscanf(fid,'%f %f %f',[5 nv])';
M.vertices = M.vertices(:,1:3);
M.faces    = fscanf(fid,'%d %d %d %d',[4 nf])';
M.faces    = M.faces(:,2:4) + 1;
fclose(fid);

figure; ax = axes;
axis(ax,'equal');
axis(ax,'off');
hp = patch(M,...
    'FaceColor', 'b',...
    'EdgeColor', 'none',...
    'Parent',ax);
camlight(ax);
camlight(ax,-80,-10);
lighting(ax,'gouraud');
set(hp,'FaceVertexCData',rand(nv,1), 'FaceColor','interp')

for i=1:3
    N = get(hp,'VertexNormals');
    normN = sqrt(sum(N.^2,2));
    normN(normN < eps) = 1;
    N     = bsxfun(@rdivide,N,normN);
    N(1:3,:)
    set(hp,'Vertices',get(hp,'Vertices')+N/400);
    drawnow
end


Matlab displays:


ans =

  3x3 single matrix

    0.1962    0.9726   -0.1248
    0.2108    0.9510   -0.2262
    0.0530    0.8026    0.5941


ans =

  3x3 single matrix

    0.1977    0.9724   -0.1239
    0.1748    0.9599   -0.2193
    0.0545    0.8016    0.5953


ans =

  3x3 single matrix

    0.1993    0.9722   -0.1230
   -0.1381    0.9828   -0.1223
    0.0554    0.8009    0.5962


while Octave displays the same initial values:


ans =

   0.196148   0.972595  -0.124835
   0.210776   0.951005  -0.226191
   0.052961   0.802618   0.594137

ans =

   0.196148   0.972595  -0.124835
   0.210776   0.951005  -0.226191
   0.052961   0.802618   0.594137

ans =

   0.196148   0.972595  -0.124835
   0.210776   0.951005  -0.226191
   0.052961   0.802618   0.594137


Guillaume <gyom>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by mmuetzel (Posted a comment)
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by gyom (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.

     

    Follow 4 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2018-11-19 mmuetzel StatusReady For Test Fixed
        Open/ClosedOpen Closed
    2018-11-16 mmuetzel StatusConfirmed Ready For Test
    2018-11-13 rik5 StatusNone Confirmed

    Back to the top

    Powered by Savane 3.13-4b48.
    Corresponding source code