Skip to content

Commit

Permalink
Merge pull request #23 from murraystevenson/curvefixes
Browse files Browse the repository at this point in the history
Curve rendering fixes - Thanks Murray!
  • Loading branch information
boberfly authored Oct 21, 2019
2 parents a9b8e8c + 2359847 commit ff9eacd
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions src/GafferCycles/IECoreCyclesPreview/CurvesAlgo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,31 +72,37 @@ ccl::Mesh *convertCommon( const IECoreScene::CurvesPrimitive *curve )
const V3fVectorData *p = curve->variableData<V3fVectorData>( "P", PrimitiveVariable::Vertex );
const vector<Imath::V3f> &points = p->readable();

vector<float> width;
PrimitiveVariableMap::const_iterator wIt = curve->variables.find( "width" );
if( wIt != curve->variables.end() )
if( const FloatVectorData *w = curve->variableData<FloatVectorData>( "width", PrimitiveVariable::Vertex ) )
{
const FloatVectorData *w = curve->variableData<FloatVectorData>( "width", PrimitiveVariable::Vertex );
const vector<float> &width = w->readable();

size_t key = 0;
for( size_t i = 0; i < numCurves; ++i )
{
size_t firstKey = key;
for( size_t j = 0; j < verticesPerCurve[i]; ++j, ++key )
cmesh->add_curve_key( ccl::make_float3( points[key].x, points[key].y, points[key].z ), width[key] );
cmesh->add_curve_key( ccl::make_float3( points[key].x, points[key].y, points[key].z ), width[key] / 2.0f );

cmesh->add_curve( i, 0 );
cmesh->add_curve( firstKey, 0 );
}
}
else
{
float constantWidth = 1.0f;

if( const FloatData *cw = curve->variableData<FloatData>( "width", PrimitiveVariable::Constant ) )
{
constantWidth = cw->readable();
}

size_t key = 0;
for( size_t i = 0; i < numCurves; ++i )
{
size_t firstKey = key;
for( size_t j = 0; j < verticesPerCurve[i]; ++j, ++key )
cmesh->add_curve_key( ccl::make_float3( points[key].x, points[key].y, points[key].z ), 1.0f );
cmesh->add_curve_key( ccl::make_float3( points[key].x, points[key].y, points[key].z ), constantWidth / 2.0f );

cmesh->add_curve( i, 0 );
cmesh->add_curve( firstKey, 0 );
}
}

Expand Down

0 comments on commit ff9eacd

Please sign in to comment.