Python generator - Culling issue



  • On 14/03/2017 at 10:16, xxxxxxxx wrote:

    Hi everyone,

    I'm experiencing some strange behaviour where polygons generated from a Python generator (this can also be replicated in an objectData plugin context) are disappearing from the viewport. This only occurs when the coordinate of the generator object cannot be seen in the viewport. This applies for Polygons but not primitives. Here's an example:

    import c4d
    from c4d import utils as u, Matrix as m, Vector as v
      
    w = 200
    h = 200
      
    off = v(1000,0,0)
      
    def main() :
        pol = c4d.BaseObject(c4d.Opolygon)
        pol.ResizeObject(4,1)
        pol.SetPoint(0,v(-w,0,-h)+off)
        pol.SetPoint(1,v( w,0,-h)+off)
        pol.SetPoint(2,v( w,0, h)+off)
        pol.SetPoint(3,v(-w,0, h)+off)
      
        pol.SetPolygon(0,c4d.CPolygon(0,1,2,3))
        
        null = c4d.BaseObject(c4d.Onull)
        
        null.SetName("PIP - Group")
        pol.InsertUnderLast(null)
        
        cube = c4d.BaseObject(c4d.Ocube)
        cube.SetAbsPos(-off)
        cube.InsertUnderLast(null)
        
        
        return null
    

    In this case, the origin is the vector where the Python Generator is located in space. If I move the camera so that the Polygon is visible but the origin is not, the polygon disappears. If I have the primitive cube in shot but not the origin, the cube still displays properly.

    Can anyone shed any light on this? Is there a camera culling feature I don't know about or something

    Thanks  :)

    Adam



  • On 15/03/2017 at 02:53, xxxxxxxx wrote:

    Hi Adam,

    like shown in the Py-RoundedTube example you need to send a MSG_UPDATE ( pol.Message (c4d.MSG_UPDATE) ) to the PolygonObject after its construction, so it can update its bounding box. Unfortunately this is mentioned in documentation for the PointObject, only. Something we definitely should improve.



  • On 15/03/2017 at 03:49, xxxxxxxx wrote:

    Thanks! I'm really glad it was that simple. :)

    Adam


Log in to reply