Limit at 512 ??



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 10/10/2012 at 18:48, xxxxxxxx wrote:

    This one is driving me crazy.
    I have the following code:

      
    def plot_bits(op,size,ncells,bd) :   
         size2=size/2.0   
         cellsizex=size.x/ncells.x   
         cellsizey=size.y/ncells.y   
         cellsizez=size.z/ncells.z   
         startx=-size2.x+(cellsizex/2.0)   
         starty=-size2.y+(cellsizey/2.0)   
         startz=-size2.z+(cellsizez/2.0)   
      
         bd.SetMatrix_Matrix(op,op.GetMg())   
         bd.SetPen(c4d.Vector(1))   
         for a in range(int(ncells.z)) :   
              for b in range(int(ncells.y)) :   
                   for c in range(int(ncells.x)) :   
                        pz=a*(1.0/ncells.z)*size.z   
                        py=b*(1.0/ncells.y)*size.y   
                        px=c*(1.0/ncells.x)*size.x   
                        pos=c4d.Vector(startx+px,starty+py,startz+pz)   
                        bd.DrawLine(pos,pos+c4d.Vector(2,0,0),c4d.NOCLIP_D)   
    

    The size parameter is a vector with the size of a box. The ncell is also a vector and it stores the grid subdivisions of the box.
    As long as ncell contains values that, multiplied with each other are lower than 512, it all plots fine. But, as soon as ncell.x*ncell.y*ncell.z is larger than 512, the plotting is ruined.
    For example, if ncell is (7,7,10) it all works fine (7*7*10=490) but if ncell is (7,7,11) it doesn't plot all the cells (7*7*11=539)
    What is wrong with this?!?



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 11/10/2012 at 05:39, xxxxxxxx wrote:

    What the hell is the matter with the number 512?!?!?
    I tried this code:

      
    obj=doc.SearchObject("Spline")   
    if obj is None: return   
    bd=doc.GetActiveBaseDraw()   
    bd.SetMatrix_Matrix(obj,obj.GetMg())   
    real_spline=obj.GetRealSpline()   
    spline_help=c4d.utils.SplineHelp()   
    spline_help.InitSpline(real_spline,c4d.Vector(0),None,True,True,True,True)   
    leng=100   
    stp=1.0/leng   
    for i in xrange(leng) :   
         offset=spline_help.GetOffsetFromReal(i*stp)   
         pos=spline_help.GetPosition(offset)*op.GetMg()   
         bd.DrawLine(pos,pos+c4d.Vector(10,0,0),c4d.NOCLIP_D)   
    

    And it works fine, drawing lines at even intervals, along the spline.
    Well, it works fine until leng=512.
    As soon as I set leng to a number larger than 512, it starts misbehaving.
    Is there anything going on that I'm not aware of?



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 11/10/2012 at 07:13, xxxxxxxx wrote:

    Hi Rui,

    I'm sorry but I can't reproduce the issue because the last code you posted is working (at least for me). I tested it in a TagData plugin with values higher than 512 and it's giving the expected result.



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 11/10/2012 at 07:20, xxxxxxxx wrote:

    This is so weird. My code above (both examples) is not working and I'm running it on an ObjectData plugin.



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 11/10/2012 at 09:51, xxxxxxxx wrote:

    Originally posted by xxxxxxxx

    This is so weird. My code above (both examples) is not working and I'm running it on an ObjectData plugin.

    Hy Rui,

    could you paste a working example, ie. the full code of the  ObjectData-Tag?

    I would like to check if it is working on my system, but I have no time to patch an example together ..

    Cheers,
    André



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 11/10/2012 at 14:43, xxxxxxxx wrote:

    You can download it from here:

    http://ruimac.com/files/Test.zip

    Just place the unzipped folder inside your plugins folder.
    The plugin name, as it is now, is Test.
    Create a Test object.
    It has a Size parameter that you can leave alone.
    It starts out with a grid size of 6,6,6
    Try setting it to 7,7,10
    All the dots are drawn.
    Now set it to 7,7,11
    Now something weird happens!!

    The other experience is even weirder.
    Create a freehand spline. Make sure it is called Spline
    As soon as it is drawn, the display gets funky.
    Now, select the Test object again.
    Adjust the Subdivisions parameter.
    It should set how many subdivisions would be drawn along the spline.
    But... it messes with the box-grid display!!!
    What could be wrong??

    Rui Batista



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 11/10/2012 at 21:16, xxxxxxxx wrote:

    I tested the scene on R12, where I don't see any dots. Grid on 7,7,11 creates a crash.

    In R13 I can see the dots, but with 7,7,11 I also get the crash. R14 didn't make it to my hd yet. But something is going on with 512 here ;)

    With R12, I do get a display of a kind of subdivided Spline in the editor. In R13 I get a crash, as soon as I create the Spline.

    I am running on Windows and an NVIDIA GTX 580 ...

    Cheers,
    André



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 12/10/2012 at 02:36, xxxxxxxx wrote:

    Thank you for looking into it, André.

    I don't get crashes, just weird display.
    Well, I do, if I save a scene containing the Test object and then trying to open it.
    There is something really weird about all this. And I was sure I was doing plain ordinary stuff.
    Could someone else take a look at this too?

    Rui Batista



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 12/10/2012 at 08:27, xxxxxxxx wrote:

    I looked at it briefly too.
    It crashes a lot for me on R13 as well.

    To make it easier to troubleshoot. I removed all of the box code stuff so only the spline code existed.
    There is definitely a hard coded size limit situation happening with the line: spline_help.GetOffsetFromReal(i*stp).
    Anything over 512 crashes C4D.

    Another weird thing is the drawn splines only show up if the mouse is over the scene view. Then disappear when the mouse is anywhere else. That seems wrong to me.
    I noticed that you're drawing with a tool plugin. But you don't have any mechanism in it to tell it to stop drawing. So the system is in a sort of infinite loop when that plugin is used.
    If I run the reload python scripts command. It crashes C4D, because your plugin is still running and trying to draw things in the background.

    My Conclusions:
    -The number 512 does seem to be a hard coded limit being used here.
     But I also asked myself..Why would I ever want to go that high with subdivisions anyway?

    -I don't think the draw method is supposed to be used like this where it's constantly running(drawing).
     It might need to be tied to something like a mouse button or keypress to turn off the draw state.
     Otherwise the plugin makes C4D very unstable.

    * Edit - I almost never make tool plugins so know very little about them. So I opened up some of my examples to see why your plugin might be crashing so badly. And I noticed that in my other tool plugin example. None of them use GetActiveBaseDraw() in them.
    That might be something to check on as well.

    *Edit2 - I also just noticed that in my other example that uses GetVirtualObjects()
    The draw code is placed inside the draw() method. Not inside the GetVirtualObjects() method.
    Not sure if that means anything important or not.

    -ScottA



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 12/10/2012 at 09:24, xxxxxxxx wrote:

    Thank you for checking it out, Scott.

    I usually do all my drawing inside the Draw method. This was just for testing. But I see that it will not work if it is not done inside the Draw method. I changed my code to perform all the drawing inside the Draw method and it works now.
    There is still that limitation of 512 subdivisions (and, although being a very large value, sometimes, for really big splines, it may be needed).
    But I guess I can leave without it being able to calculate more than 512 subdivisions ;-)

    Rui Batista



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 19/10/2012 at 04:27, xxxxxxxx wrote:

    Originally posted by xxxxxxxx

    There is still that limitation of 512 subdivisions (and, although being a very large value, sometimes, for really big splines, it may be needed).
    But I guess I can leave without it being able to calculate more than 512 subdivisions ;-)

    I've checked this and can't confirm.
    How did you found that SplineHelp.GetOffsetFromReal() has a limit of 512 subdivisions?

    With the spline case, if we print the offset calculated with 600 subdivisions we get valid values for 1/600, 2/600 etc.



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 19/10/2012 at 04:38, xxxxxxxx wrote:

    Well, the code posted above was not working for subdivisions over 512.



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 19/10/2012 at 04:39, xxxxxxxx wrote:

    Originally posted by xxxxxxxx

    Well, the code posted above was not working for subdivisions over 512.

    It does work, this is why I'm wondering why you said that over 512 subdivisons it didn't worked.



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 19/10/2012 at 04:47, xxxxxxxx wrote:

    It didn't, here.
    But I believe now that it was due to the fact that I was not doing the plotting inside the Draw method.
    What is strange is that it occurred with the 512 limit. And since 512 is a power-of-two number, I considered that it could be in fact a preset limit.



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 19/10/2012 at 04:51, xxxxxxxx wrote:

    Originally posted by xxxxxxxx

    It didn't, here.
    But I believe now that it was due to the fact that I was not doing the plotting inside the Draw method.
    What is strange is that it occurred with the 512 limit. And since 512 is a power-of-two number, I considered that it could be in fact a preset limit.

    Ok, I understand now. The issue wasn't because of the spline but was related to the drawing done inside of GetVirtualObjects() instead of Draw().



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 19/10/2012 at 05:00, xxxxxxxx wrote:

    Exactly.
    But it is a pain to have to do all the drawing inside the Draw method. Sometime it is necessary to test out something elsewhere and, when the best way to check out the results is to draw something on the screen, this requires that the code has to be adjusted to perform the checking inside the Draw method :-(


Log in to reply