Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware 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
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    Sweep Modifier

    Cinema 4D SDK
    2025 c++ windows
    3
    4
    487
    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.
    • J
      JohnThomas
      last edited by JohnThomas

      Hello,

      I'm working on a modifer object that is meant to modify a spline object by changing the number of points in the spline. In the process of doing so I encountered some peculiar behaviour with the Sweep object when it interacts with my modifer.

      For the boiled down code I used the Spherify example from the sdk with the only modification to ModifyObject.

      Bool Spherify::ModifyObject(const BaseObject* mod, const BaseDocument* doc, BaseObject* op, const Matrix& op_mg, const Matrix& mod_mg, Float lod, Int32 flags, BaseThread* thread) const
      {
      	SplineObject* spline = (SplineObject*)op;
      	if (spline)
      	{
      		spline->ResizeObject(4, 1);
      
      		Segment* splineSegment = spline->GetSegmentW();
      		Vector* splinePoints = spline->GetPointW();
      
      		splineSegment[0].cnt = 4;
      		splineSegment[0].closed = FALSE;
      		splinePoints[0] = Vector(0, 100, 0);
      		splinePoints[1] = Vector(0, 0, 0);
      		splinePoints[2] = Vector(100, 0, 0);
      		splinePoints[3] = Vector(100, 100, 0);
      
      		op->Message(MSG_UPDATE);
      
      	}
      	return TRUE;
      }
      

      Am I missing something obvious with the way that Sweep operates that is causing this behaviour or am I missing something from my code that would prevent this?

      Any help would be greatly appreciated.

      John Thomas

      i_mazlovI 1 Reply Last reply Reply Quote 0
      • i_mazlovI
        i_mazlov @JohnThomas
        last edited by

        Hi John,

        Having a modifier that changes the number of points (especially when you reduce them) isn't a very good idea, because in some setups you can have some dependencies that would be at least broken or even lead to the unstable execution. I think a better idea in this case would be to look in the direction of a generator object instead.

        With that's said, I've just briefly checked your code in the latest Cinema 4D version (that hasn't been release yet) and the issue is not reproducible there. This might be due to the undefined behavior of such modifier or due to some internal changes that I'm not aware of, this I can't say for sure.

        Cheers,
        Ilia

        MAXON SDK Specialist
        developers.maxon.net

        J 1 Reply Last reply Reply Quote 0
        • J
          JohnThomas @i_mazlov
          last edited by

          @i_mazlov Thanks for the response. I was afraid that that would be the case.

          John Thomas

          ferdinandF 1 Reply Last reply Reply Quote 0
          • ferdinandF
            ferdinand @JohnThomas
            last edited by ferdinand

            Hey,

            Please note that both options, a modifier that changes the number of points of its host, and a spline generator that has another spline as an input, are not great. We have internally two cases that do exactly these two things: The bevel deformer and the spline mask spline generator. But third parties do not easily replicate both because they require detailed knowledge of our API and in some cases access to non-public things.

            For deformers, Ilia already gave a great explanation. In short, if you are not careful, you can crash Cinema 4D. For the other case, a spline generator which takes another spline as an input, you will run into the issue that splines are not intended to have as objects as inputs. This means you are not getting passed a HierarchyHelp in ObjectData::GetContour with which you could ensure that your child object dependencies are up to date (because by default they are being built after you). There are patterns to solve this, and you run here at worst into the problem of a laggy/malfunctioning plugin and no crashes. But I would still advise going down that rabbit hole when avoidable.

            When you really must do this and now want to go down the spline generator road, I would recommend opening a new topic on that before you start.

            Cheers,
            Ferdinand

            MAXON SDK Specialist
            developers.maxon.net

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