Use OutputGeometryPart::computeCurves to clean curves
#include "types.h"
#include "util.h"
-static void
-clearCurvesBuilder(
- MArrayDataBuilder &curvesBuilder,
- int count
- )
-{
- for(int i = (int) curvesBuilder.elementCount();
- i-- > count;)
- {
- curvesBuilder.removeElement(i);
- }
-}
-
-static void
-clearCurves(
- MDataHandle &curvesHandle,
- MDataHandle &curvesIsBezier
- )
-{
- MArrayDataHandle curvesArrayHandle(curvesHandle);
- MArrayDataBuilder curvesBuilder = curvesArrayHandle.builder();
-
- clearCurvesBuilder(curvesBuilder, 0);
-
- curvesArrayHandle.set(curvesBuilder);
-
- curvesIsBezier.setBool(false);
-}
-
OutputGeometryPart::OutputGeometryPart(
HAPI_NodeId nodeId,
HAPI_PartId partId
@@ -240,19 +211,11 @@ OutputGeometryPart::compute(
MDataHandle curvesHandle = partHandle.child(AssetNode::outputPartCurves);
MDataHandle curvesIsBezierHandle =
partHandle.child(AssetNode::outputPartCurvesIsBezier);
- if(myPartInfo.type == HAPI_PARTTYPE_CURVE
- && myCurveInfo.curveCount)
- {
computeCurves(time,
partPlug.child(AssetNode::outputPartCurves),
partPlug.child(AssetNode::outputPartCurvesIsBezier),
data,
curvesHandle, curvesIsBezierHandle);
- }
- else
- {
- clearCurves(curvesHandle, curvesIsBezierHandle);
- }
// Instancer
MDataHandle hasInstancerHandle = partHandle.child(AssetNode::outputPartHasInstancer);
@@ -308,8 +271,14 @@ OutputGeometryPart::computeCurves(
MArrayDataHandle curvesArrayHandle(curvesHandle);
MArrayDataBuilder curvesBuilder = curvesArrayHandle.builder();
+ int curveCount = 0;
+ if(myPartInfo.type == HAPI_PARTTYPE_CURVE
+ && myCurveInfo.curveCount)
+ {
HAPI_AttributeInfo attrInfo;
+ curveCount = myCurveInfo.curveCount;
+
std::vector<float> pArray, pwArray;
hapiGetPointAttribute(
myNodeId, myPartId,
@@ -468,16 +437,21 @@ OutputGeometryPart::computeCurves(
knotOffset += numVertices + order;
}
+ curvesIsBezierHandle.setBool(
+ myCurveInfo.curveType == HAPI_CURVETYPE_BEZIER
+ );
+ }
+
// There may be curves created in the previous cook. So we need to clear
// the output attributes to remove any curves that may have been created
// previously.
- clearCurvesBuilder(curvesBuilder, myCurveInfo.curveCount);
+ for(int i = (int) curvesBuilder.elementCount();
+ i-- > curveCount;)
+ {
+ curvesBuilder.removeElement(i);
+ }
curvesArrayHandle.set(curvesBuilder);
-
- curvesIsBezierHandle.setBool(
- myCurveInfo.curveType == HAPI_CURVETYPE_BEZIER
- );
}
template<typename T>
