Your browser does not seem to support JavaScript. As a result, your viewing experience will be diminished, and you have been placed in read-only mode.
Please download a browser that supports JavaScript, or enable it if it's disabled (i.e. NoScript).
If anyone interested:
def MatrixBlend(mxA, mxB, t): quatA = c4d.Quaternion() quatA.SetMatrix(mxA) quatB = c4d.Quaternion() quatB.SetMatrix(mxB) return utils.MatrixMove( utils.MixVec(mxA.off, mxB.off, t) ) * utils.QSlerp(quatA, quatB, t).GetMatrix() * utils.MatrixScale( utils.MixVec(mxA.GetScale(), mxB.GetScale(), t) )
@ferdinand said in Touch input objects withot resetting its cache:
NBIT_EHIDE
Sorry Ferdinand, I might be not a great explainer... But that not I actually need. This bit only hides object in Editor, in Render it's still visible.
So Touch() is the only way to truly hide the object. My only issue is that I'm trying to hide all nested objects with Touch(). And when I'm doing it I'm also touching the grandchildren, and this cause their parent to be rebuilt. I'm looking for a way to skip objects which already touched by their parent generator.
To be clear, here's the use case: +--Null whole tree has to be hidden | +--Loft has BIT_CONTROLOBJECT, has OBJECT_INPUT — not hidden yet, has to be hidden | | +--Circle has BIT_CONTROLOBJECT — already hidden by parent Loft, has to be skipped | +--Loft has BIT_CONTROLOBJECT, has OBJECT_INPUT — not hidden yet, has to be hidden | | +--Cube has BIT_CONTROLOBJECT — not hidden by parent Loft, has to be hidden +--... +--MY_GENERATOR has object link pointing to Null, it wants to hide this Null
whole tree has to be hidden
has BIT_CONTROLOBJECT, has OBJECT_INPUT — not hidden yet, has to be hidden
has BIT_CONTROLOBJECT — already hidden by parent Loft, has to be skipped
has BIT_CONTROLOBJECT — not hidden by parent Loft, has to be hidden
has object link pointing to Null, it wants to hide this Null
If I'll try to Touch() Circle spline, then it's parent Loft would be continuously regenerating, so MY_GENERATOR would be also continuously regenerating, because source dirtiness is changed.
If I'll try to skip Touch() children of objects with OBJECT_INPUT set, then Cube under Loft would be visible - because it wasn't touched by its parent Loft as Cube is not a spline object.
So either I go into regeneration loop, either I'm not hiding objects. But I want both performance and hide.
@ferdinand thanks for suggestion, I'll try it as well.
Here's setup:
SCENE_ROOT +--SOME_SOURCE (whole tree has to be hidden) | +--SOURCE_CHILD_1 | | +--SOURCE_GRANDCHILD_1_1 | | +--... | | +--SOURCE_GRANDCHILD_1_N | +--SOURCE_CHILD_N | | +--SOURCE_GRANDCHILD_N_1 | | +--... | | +--SOURCE_GRANDCHILD_N_N +--... +--MY_GENERATOR (has object link pointing to SOME_SOURCE)
The idea is to create similar functionality as Connect object has - object link as a mesh source, and this source (whole tree) has to be hidden. Touch is resetting object cache, what I want to avoid. While GetAndCheckHierarchyClone is able to hide whole subtree, keeping it's cache.
Touch
GetAndCheckHierarchyClone
@ferdinand thanks for explanations and example.
Hi,
I'd like to know if there's a chance to hide objects the same way it's done in GetAndCheckHierarchyClone() method. Generally GACHC is hiding children geometry without destroying their cache, and it don't reset DIRTYFLAGS_CACHE. I'd like to do the similar thing to the dependencies, which aren't children.
Currently I know only Touch() method, but it reset caches and enforce all generators to be recalculated when touching the chain. I seen many similar topics were related to the Touch() method, but there were no solution.
Also are there any flags to know if object is made hidden by GetAndCheckHierarchyClone? At least I try to skip Touching for these objects. GetCache() is returning some value, testing BIT_CONTROLOBJECT is not relevant as it set for both Generator and Input objects.
@ferdinand huge thanks for detailed reply, as always.
PointObject::DisplayPoints
Hi, I would like to draw a spline similar way it's drawing in the editor, with gradient from white to blue, and the points. As well as I'd like the points to be selectable.
I've came to this for now:
import c4d class SplineTest(c4d.plugins.ObjectData): def Init(self, op): self.LINE_DRAW = None return True def GetVirtualObjects(self, op, hh): hierarchyCloneRes = op.GetAndCheckHierarchyClone(hh, op.GetDown(), c4d.HIERARCHYCLONEFLAGS_ASSPLINE, False) if op.GetDown() else None spline = c4d.SplineObject(0, c4d.SPLINETYPE_LINEAR) if hierarchyCloneRes: if not hierarchyCloneRes["dirty"]: return hierarchyCloneRes["clone"] if hierarchyCloneRes["clone"].IsInstanceOf(c4d.Ospline) or hierarchyCloneRes["clone"].IsInstanceOf(c4d.Oline): spline = hierarchyCloneRes["clone"] sh = c4d.utils.SplineHelp() if sh.InitSplineWith(spline, c4d.SPLINEHELPFLAGS_RETAINLINEOBJECT): self.LINE_DRAW = sh.GetLineObject().GetClone() sh.FreeSpline() return spline def Draw(self, op, drawpass, bd, bh): doc = bh.GetDocument() if drawpass != c4d.DRAWPASS_OBJECT or self.LINE_DRAW is None or self.LINE_DRAW.GetPointCount() == 0 or not bh.IsActive() or not doc.IsEditMode(): return c4d.DRAWRESULT_SKIP # this draw is ignored bd.DrawPolygonObject(bh, self.LINE_DRAW, c4d.DRAWOBJECT_USE_CUSTOM_COLOR, None, c4d.GetViewColor(c4d.VIEWCOLOR_SPLINESTART), ) if doc.GetMode() == c4d.Mpoints: opPoints = self.LINE_DRAW.GetAllPoints() pSelection = self.LINE_DRAW.GetPointS().GetAll(len(opPoints)) selected = [opPoints[index] for index, isSelected in enumerate(pSelection) if isSelected] nonselected = [opPoints[index] for index, isSelected in enumerate(pSelection) if not isSelected] bd.SetMatrix_Matrix(op, bh.GetMg()) bd.SetPointSize(6) bd.LineZOffset(2) if len(nonselected): bd.SetPen(c4d.GetViewColor(c4d.VIEWCOLOR_INACTIVEPOINT)) bd.DrawPoints(nonselected) if len(selected): bd.SetPen(c4d.GetViewColor(c4d.VIEWCOLOR_ACTIVEPOINT)) bd.DrawPoints(selected) return c4d.DRAWRESULT_OK if __name__ == "__main__": c4d.plugins.RegisterObjectPlugin(id = 1000001, str = 'SplineTest', g = SplineTest, description = "osplinetest", icon = None, info = c4d.OBJECT_GENERATOR | c4d.OBJECT_INPUT | c4d.OBJECT_ISSPLINE)
Issue is object lines are not being drawn with custom color. Instead this object is drawn as maybe with c4d.VIEWCOLOR_ACTIVEBOX (visually its drawn as orange in R25)
Hi C4D team. Is that functionality still under development?
@m_magalhaes Thanks Manuel, I appreciate your wise support every time.
Merry Xmas and Happy New Year!
@m_magalhaes Hi Manuel,
Thanks for the reply.
c4d.DIRTYFLAGS_DESCRIPTION | c4d.DIRTYFLAGS_DATA | c4d.DIRTYFLAGS_CHILDREN | c4d.DIRTYFLAGS_CACHE
IsolateObjects
ExecutePasses
baseObject.GetInfo() & c4d.OBJECT_INPUT
I need alternative to GetCache(), and CSTO seems to be a good option. But Python tag produces wrong geometry when executed over clone of the object with CSTO. It additionally produces geometry which should be hidden by parent generators (for ex. Cloner under Volume Builder). Behavior is the same in Python Expression, or Python Tag Plugin, and it affects Cinema4D R21+ at the least.
Here's the code:
srcClone = srcObj.GetClone(c4d.COPYFLAGS_NO_ANIMATION) doc.InsertObject(srcClone) cstoResult = c4d.utils.SendModelingCommand( command=c4d.MCOMMAND_CURRENTSTATETOOBJECT, list = [srcClone], mode = c4d.MODELINGCOMMANDMODE_ALL, bc = c4d.BaseContainer(), doc = doc ) srcClone.Remove() for resObj in cstoResult: for resChildObj in HierarchyIterator(resObj.GetDown()): cloneObject = resChildObj.GetClone(c4d.COPYFLAGS_NO_HIERARCHY) cloneObject.InsertUnderLast(selfObj)
Viewport:
Don't like the idea to call CSTO over original object, because it rebuilds object cache and affect DIRTYFLAGS_CACHE. What's the issue, is it possible to resolve it?
Plugin https://www.dropbox.com/s/fxz8g7p8uuwc5y0/c4d_tag_csto.zip?dl=0 Scene simple csto test.c4d
Thanks.