Results 1 to 10 of 10

Thread: Remove points and polys in Layout

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    creacon
    Join Date
    Nov 2005
    Location
    Belgium
    Posts
    1,300

    Remove points and polys in Layout

    Hi,

    I am creating a mesh in Layout using a modeler command, and that seems to work fine.
    But before I create the next mesh I have to destroy the one that was created the step before.

    I tried to use the fastPointScan to iterate over the points and remove them using remPoint.
    Removing points from a set you're iterating over seems dangerous to me , but it works. But it is incredibly slow (about 15000 times slower than it should be)

    Then I tried to issue the modeler command ModCommand_Remove, it also works but is as slow as the previous one.

    It's my guess that this has something to do with the underlying undo system.
    So the question is what is the fastest way to remove all points/polys from an object (in layout)?

    creacon

  2. #2
    TrueArt Support
    Join Date
    Feb 2003
    Location
    Poland
    Posts
    7,993
    In Modeler's C/C++ plugin we need to delete polygon prior deleting any point.
    I would be surprised if in Layout would be different.
    remPoly() or remPoint() is not deleting them,
    just marking element for deletion,
    at the end of operation,
    It's just a flag.

    Try using normal pointScan()/polyScan() instead,
    instead of their fast... version,
    to see whether slow down is also visible.

    Are you calling done()?

  3. #3
    creacon
    Join Date
    Nov 2005
    Location
    Belgium
    Posts
    1,300
    I'm first removing the polygons then the points, then calling done. When I press "w" in layout I can see that they're removed.
    I just tried the regular pointscan and polyscan and they're even slower.

    Creating 100.000+ vertices and 200.000+ quads takes less than a second, removing them (fast version) takes 15 seconds and 40 seconds in the regular version.
    This is in the debug version, release is faster of course but still way too slow.

    I wonder if an object replacement plugin would be faster, just destroying the object at each time step.

    creacon



    Quote Originally Posted by Sensei View Post
    In Modeler's C/C++ plugin we need to delete polygon prior deleting any point.
    I would be surprised if in Layout would be different.
    remPoly() or remPoint() is not deleting them,
    just marking element for deletion,
    at the end of operation,
    It's just a flag.

    Try using normal pointScan()/polyScan() instead,
    instead of their fast... version,
    to see whether slow down is also visible.

    Are you calling done()?

  4. #4
    Electron wrangler jwiede's Avatar
    Join Date
    Aug 2007
    Location
    San Jose, CA
    Posts
    6,790
    Quote Originally Posted by creacon View Post
    I'm first removing the polygons then the points, then calling done. When I press "w" in layout I can see that they're removed.
    I just tried the regular pointscan and polyscan and they're even slower.

    Creating 100.000+ vertices and 200.000+ quads takes less than a second, removing them (fast version) takes 15 seconds and 40 seconds in the regular version.
    This is in the debug version, release is faster of course but still way too slow.
    Is your iterator a forward-iterator or backwards-iterator? If forward, it's possible the act of removing the point is causing a dynamic array to copy-by-remaining-elements in order to bring the next point to the front of the array, or something strange like that. You might consider trying a backwards iterator if it isn't already.

    Without better notion of the backing data structures, and/or some notion of how iteration and deletion are implemented, it's difficult to give much useful help.
    John W.
    LW2015.3UB/2019.1.5 on MacPro(12C/24T/10.13.6),64GB RAM, NV 980ti

  5. #5
    creacon
    Join Date
    Nov 2005
    Location
    Belgium
    Posts
    1,300
    I was thinking the exact same thing, but the thing is that it is not "my" iterator, it's LW's. (pointscan, fastpointscan), it's a callback for every point in the mesh.
    The chance is that it is indeed a forward iterator and that I am removing elements at the front of the array and that the realocation is causing the slowdown.

    creacon





    Quote Originally Posted by jwiede View Post
    Is your iterator a forward-iterator or backwards-iterator? If forward, it's possible the act of removing the point is causing a dynamic array to copy-by-remaining-elements in order to bring the next point to the front of the array, or something strange like that. You might consider trying a backwards iterator if it isn't already.

    Without better notion of the backing data structures, and/or some notion of how iteration and deletion are implemented, it's difficult to give much useful help.

  6. #6
    TrueArt Support
    Join Date
    Feb 2003
    Location
    Poland
    Posts
    7,993
    Maybe Layout is constantly refreshing viewports after each removed element?
    This is the case in Modeler select element functions,
    causing a lot of slowdown.

    There is Layout command

    InteractiveMode nonoff
    Switches the interactive viewport redraw(respecting the bounding box threshold) flag on/off.
    Switch on(1) for starting interactive mode redraws, off(0) to switch back to full redraws.
    Set this flag for the duration of mouse dragging in plugin panels when interactive viewport updates are desired.

    Maybe try switching off viewports,
    and/or try using above command and see what happens.

    Try adding fprintf() time() (to some log file) to inside of scanning callbacks (or before it, and after ending), to see how much CPU in spending time in them.
    Maybe it's just in done() wasting all time?

    What is showing Task Manager? What is CPU usage while removing elements.. ?

  7. #7
    creacon
    Join Date
    Nov 2005
    Location
    Belgium
    Posts
    1,300
    For now I am continuing to use the ModCommand_Remove until a better solution comes along.
    It's not fast but at least it works.

    Thanks for your help.

    creacon

  8. #8
    TrueArt Support
    Join Date
    Feb 2003
    Location
    Poland
    Posts
    7,993
    LWMeshDataEdit, at least in Modeler, is marking element for deletion later, not deleting immediately.
    However it could be theoretically implemented differently in Layout.
    But there should be a way for verifying it.
    pointScan() can be run second time.
    points on which we used remPoint() should have delete flag turned on. And still exists for scanning routine.

  9. #9
    creacon
    Join Date
    Nov 2005
    Location
    Belgium
    Posts
    1,300
    Sensei,

    for as far as I know, the LWMeshDataEdit is the exact same one as in modeler, so it works in the exact same way.
    They implemented all the modeler functionality in Layout ages ago and then decided to do something else ;-). Anyway I have a temp solution and will come back to this problem later.

    creacon

    Quote Originally Posted by Sensei View Post
    LWMeshDataEdit, at least in Modeler, is marking element for deletion later, not deleting immediately.
    However it could be theoretically implemented differently in Layout.
    But there should be a way for verifying it.
    pointScan() can be run second time.
    points on which we used remPoint() should have delete flag turned on. And still exists for scanning routine.

  10. #10
    TrueArt Support
    Join Date
    Feb 2003
    Location
    Poland
    Posts
    7,993
    Quote Originally Posted by creacon View Post
    for as far as I know, the LWMeshDataEdit is the exact same one as in modeler, so it works in the exact same way.
    It's LWSDK header that is (and must be) the same.
    How it's implemented internally, only authors know.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •