Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush Python API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Recent
    • Tags
    • Users
    • Login

    utils.CheckViewPortSelect bugs

    Scheduled Pinned Locked Moved PYTHON Development
    1 Posts 0 Posters 158 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • H Offline
      Helper
      last edited by

      On 16/06/2013 at 05:46, xxxxxxxx wrote:

      Hi,

      sorry for the second thread, but I am pretty sure now that this a python specific problem.

      1. When you do invoke Init() on a ViewPortSelect instance multiple times with different
      objects as the ops parameter list the instance produces memory leaks. This of course
      assumes the case where the ViewPortSelect object is a class member.

      2. The same goes for a ViewPortSelect instance which is initialized right away for multiple
      objects. The method that triggers the whole mess seems to be then the PickObject() method.

      3. Freeing the ViewPortSelect  class member by overwriting it with None when freeing the 
      tool does not free the associated memory. The crucial part seems to be somehow the
      reinitialization of the instance as described in 1.

      4. ViewPortSelect.PickObject() does not respect the object list passed to Init() it will select
      anything that is near to the cursor. Not sure if that is intended, but it should be at least 
      mentioned more clearly.

      Why all that mess you might ask, simply do not make it a class member. Well, that is true,
      but I think these are still major bugs and also dynamically allocating the ViewPortSelect 
      object is quite a performance problem in python, at least for larger objects.

      def CheckViewPortSelect(self, doc, bd) :
          """
          Tests if the vpselect object if it is till valid.
          :param doc : The active document.
          :param bd  : The associated BaseDraw.
          :return    : NYI - always True
          """
          if not isinstance(self.vpselect, utils.ViewportSelect) :
              self.vpselect = utils.ViewportSelect()
          if self.aobject is not None:
              if ( bd.GetMg() != self.vpmatrix or 
                   bd.GetFrame() != self.vpframe or 
                   self.vpobject != self.aobject or
                   bd.GetProjection() != self.vpproject ) :
                  self.vpselect = utils.ViewportSelect() # without that line the ViewportSelect is producing leaks.
                  self.vpmatrix = bd.GetMg()        
                  self.vpframe = bd.GetFrame()     
                  self.vpproject = bd.GetProjection()
                  self.vpobject = self.aobject
                  wd = self.vpframe["cr"] - self.vpframe["cl"] + 1
                  hg = self.vpframe["cb"] - self.vpframe["ct"] + 1
                  self.vpselect.Init( wd, hg, bd, [self.aobject], c4d.Mpolyedgepoint, True, c4d.VIEWPORTSELECTFLAGS_IGNORE_HIDDEN_SEL )
              return True
          return False
      

      Happy rendering,
      Ferdinand

      1 Reply Last reply Reply Quote 0
      • First post
        Last post