octave-patch-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Octave-patch-tracker] [patch #8951] Calculate vertexnormals for patch o


From: Markus Mützel
Subject: [Octave-patch-tracker] [patch #8951] Calculate vertexnormals for patch objects
Date: Tue, 12 Apr 2016 06:52:49 +0000
User-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:46.0) Gecko/20100101 Firefox/46.0

Follow-up Comment #4, patch #8951 (project octave):

Pantxo:

Thank you for reviewing this patch.

The reason, I only implemented "VertexNormals" is that I only had Matlab
R2012a to compare to. In that version, there was no "FaceNormals". Also
"VertexNormalsMode" was called "NormalMode" then. Maybe it would be a good
idea to keep the deprecated property "NormalMode" around for legacy to mirror
"VertexNormalsMode". Otherwise, some older code might not run as expected. 

As you already pointed out, "FaceNormals" are calculated on the way. So it
should not be too hard to implement that property with the same patch.

With that older Matlab version, the "VertexNormals" are calculated whenever
"NormalMode" is set to "auto" (default), even if no light object is present in
the same axes. However, they are only really needed when lights are present.
Thus, especially if Matlab changed that behavior in more recent versions, I am
happy to adapt the code for this. Which circumstances must be met exactly to
trigger normals calculation?
That would however mean that the code would be harder to test since light
objects are (not yet) available in Octave. So maybe wait with this change for
a later version of the patch or implement a temporary trigger for testing?

I did not really time it for large patches but did not notice significant
performance hits with "normal" ones due to this patch. I will try to do this.

Good you mentioned it because I did not check before: Matlab R2012a supports
non planar patches:

p.Vertices = [0, 1, 0; 1, 1, 0; 0, 0, 0; 0, 0, 1];
p.Faces = [1 2 3 4];

hp = patch (p);

view (3)

get(hp, 'VertexNormals')

ans =

     0     0     1
     0     0     1
     0     0     1
     1     0     0


However, the VertexNormals calculated in this case are different from what
would be calculated with my patch. I will try to figure out how to do
better...
Do you have access to a newer version of Matlab and give the results for the
above example (maybe after calling "light()" or what else is necessary to
activate normal calculation)? What value does "FaceNormals" have for that
non-planar patch?

This code example does not work in Octave 4.0.1 erroring out with a syntax
error. With changed syntax, Octave produces a patch that looks different from
Matlab:

p.Vertices = [0, 1, 0; 1, 1, 0; 0, 0, 0; 0, 0, 1];
p.Faces = [1 2 3 4];

patch ("Vertices", p.Vertices, "Faces", p.Faces)

view (3)


I think these are however two unrelated bugs. Fields with uppercase letters
are not correctly recognized in Octave.

I will file two separate bug reports for these issues if not yet reported.

The weights for the average in step 2 are the lengths of the normal vectors.
These are not normalized in step 1. Thus, normal vectors from larger triangles
have a higher weight.

    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/patch/?8951>

_______________________________________________
  Nachricht gesendet von/durch Savannah
  http://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]