bugGNU Octave - Bugs: bug #54970, Use of camlight when a patch is...

 
 

bug #54970: Use of camlight when a patch is not visible

Submitter:  Guillaume <gyom>
Submitted:  Tue 06 Nov 2018 04:11:34 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
   

Jump to the original submission

Mon 12 Nov 2018 01:45:49 PM UTC, comment #12: 

I opened bug #55014 for this. Thank you!

Guillaume <gyom>
Mon 12 Nov 2018 12:28:57 PM UTC, comment #11: 

That doesn't ring a bell immediately.
Can you please open a new bug report with a small example?
Thanks.

Markus Mützel <mmuetzel>
Group administrator
Mon 12 Nov 2018 11:52:04 AM UTC, comment #10: 

Thanks, I'm trying to assess how much visible differences have to be expected compared to a sign of an underlying bug.
In this particular instance, it seems that there is still a situation where normals are not updated. It's in a loop where vertices of a patch are modified at each iteration (set(p, "Vertices", v)). If it rings a bell to you, let me know or I'll come up with a small example and open a new bug report for it.

Guillaume <gyom>
Mon 12 Nov 2018 11:14:24 AM UTC, comment #9: 

While I don't expect them to be identical, the results should be fairly similar in Matlab and Octave.
If they aren't, that might be a bug.

Do you notice any differences?

Markus Mützel <mmuetzel>
Group administrator
Mon 12 Nov 2018 11:08:26 AM UTC, comment #8: 

Thanks a lot for this, Markus, it now works well. The fix for the normals is also very useful. More generally, should we expect the exact same rendering between Matlab and Octave (apart from things like anti-aliasing)?

Guillaume <gyom>
Sat 10 Nov 2018 02:48:53 PM UTC, comment #7: 

Everything works as expected now with the sample code.  Marking as fixed and closing report.

Rik <rik5>
Group administrator
Fri 09 Nov 2018 07:28:59 PM UTC, comment #6: 

Thanks, Pantxo and Rik for the help. Very much appreciated.

I pushed a change that should fix this issue here:
http://hg.savannah.gnu.org/hgweb/octave/rev/10145b9ad883

There was also a problem when FaceNormals for surface objects were calculated on a non-regular grid which should be fixed by this change:
http://hg.savannah.gnu.org/hgweb/octave/rev/28515ed95007

Markus Mützel <mmuetzel>
Group administrator
Thu 08 Nov 2018 03:59:06 PM UTC, comment #5: 

@Markus: Pantxo beat me to it, but that was the approach I was thinking of as well.

Rik <rik5>
Group administrator
Thu 08 Nov 2018 08:23:39 AM UTC, comment #4: 

@Markus: you need to add a "u" to base_properties::visible, make base_properties::update_visible virtual and overload it in patch::properties. The following works for me:


diff -r 8195c04c596f libinterp/corefcn/graphics.in.h
--- a/libinterp/corefcn/graphics.in.h   Thu Nov 08 09:05:24 2018 +0100
+++ b/libinterp/corefcn/graphics.in.h   Thu Nov 08 09:20:26 2018 +0100
@@ -2378,7 +2378,7 @@
     string_property type frs , ty
     handle_property uicontextmenu u , graphics_handle ()
     any_property userdata , Matrix ()
-    bool_property visible , "on"
+    bool_property visible u , "on"

     // Octave-specific properties
     bool_property __modified__ hs , "on"
@@ -2387,6 +2387,8 @@

   virtual void update_handlevisibility (void);

+  virtual void update_visible (void) { };
+
 protected:
   struct cmp_caseless_str
   {
@@ -4893,6 +4895,7 @@
   private:
     std::string bad_data_msg;

+    void update_visible (void) { /* Do something */ };
     void update_faces (void) { update_data ();}

     void update_vertices (void) { update_data ();}


Pantxo Diribarne <pantxo>
Group Member
Thu 08 Nov 2018 07:41:44 AM UTC, comment #3: 

I had a very short look at this patch. My first thought was that we might want to add an update_visible function to patch (and surface).
But that doesn't seem to work as I expected: Adding a line for the "visible" property to the block of other properties with an "u" basically renders the visible property non-functional: The patch is always visible.
Is there some special way to overload functions for properties that are inherited from "base_properties" in general or the "visible" property in particular?

Markus Mützel <mmuetzel>
Group administrator
Tue 06 Nov 2018 04:35:39 PM UTC, comment #2: 

Here is the output from Matlab:


>> P = patch  ('Vertices', vertices, 'Faces', faces, ...
        'FaceVertexCData', jet (5), 'FaceColor', 'interp', ...
        'Parent', A, 'Visible', 'off');
>>
>> get (P, 'FaceNormals')

ans =

     []

>> L = camlight(A, 'headlight');
>> get (P, 'FaceNormals')

ans =

     []

>> set (P, 'Visible', 'on');
>> get (P, 'FaceNormals')

ans =

  4x3 single matrix

         0    0.8944   -0.4472
   -0.8944         0   -0.4472
         0   -0.8944   -0.4472
    0.8944         0   -0.4472


Guillaume <gyom>
Tue 06 Nov 2018 04:26:32 PM UTC, comment #1: 

@Markus: Adding you to the CC list for this bug.  Apparently this is caused by the fact that the "FaceNormals" aren't calculated when the patch object is invisible.

@Guillaume: Can you try a modification of the code in Matlab?


H = figure;
A = axes('Parent',H);

vertices = [0, 0, 0;
            1, 0, 0;
            1, 1, 0;
            0, 1, 0;
            0.5, 0.5, 1];
faces = [1, 2, 5;
         2, 3, 5;
         3, 4, 5;
         4, 1, 5];
P = patch  ('Vertices', vertices, 'Faces', faces, ...
        'FaceVertexCData', jet (5), 'FaceColor', 'interp', ...
        'Parent', A, 'Visible', 'off');

get (P, 'FaceNormals')
L = camlight(A, 'headlight');
get (P, 'FaceNormals')
set (P, 'Visible', 'on');
get (P, 'FaceNormals')



Rik <rik5>
Group administrator
Tue 06 Nov 2018 04:11:34 PM UTC, original submission:  

If camlight is called while a patch is not visible, it does not seem to be effective when the patch is set to visible. To see this effect, run the following twice, setting the "visible" property of the patch "on" or "off".


H = figure;
A = axes("Parent",H);

vertices = [0, 0, 0;
            1, 0, 0;
            1, 1, 0;
            0, 1, 0;
            0.5, 0.5, 1];
faces = [1, 2, 5;
         2, 3, 5;
         3, 4, 5;
         4, 1, 5];
P = patch  ("Vertices", vertices, "Faces", faces, ...
        "FaceVertexCData", jet (5), "FaceColor", "interp", ...
        "Parent", A, "Visible", "off"); # change here to "on"

L = camlight(A, "headlight");
set(P,"Visible","on");


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 pantxo (Posted a comment)
  • -email is unavailable- added by mmuetzel (Posted a comment)
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by rik5
  • -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 6 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2018-11-10 rik5 StatusReady For Test Fixed
        Open/ClosedOpen Closed
    2018-11-09 mmuetzel StatusConfirmed Ready For Test
    2018-11-08 mmuetzel Operating SystemGNU/Linux Any
    2018-11-06 rik5 StatusNone Confirmed
        Carbon-Copy- Added mmuetzel

    Back to the top

    Powered by Savane 3.13-4b48.
    Corresponding source code