Skip to content

Commit e45ac17

Browse files
committed
Merge pull request #435 from davidsminor/sxPredefParameters
Changed SXExecutor parameter interpretation
2 parents b7a73c7 + f155aba commit e45ac17

File tree

2 files changed

+33
-11
lines changed

2 files changed

+33
-11
lines changed

src/IECoreRI/SXExecutor.cpp

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,12 +256,34 @@ class SXExecutor::Implementation : public IECore::RefCounted
256256
}
257257
}
258258

259+
bool parameterTypesConsistent( SxType type, IECore::TypeId typeId ) const
260+
{
261+
switch( typeId )
262+
{
263+
case FloatVectorDataTypeId :
264+
return type == SxFloat;
265+
case V3fVectorDataTypeId :
266+
case V3fDataTypeId :
267+
return type == SxVector || type == SxNormal || type == SxPoint;
268+
case Color3fVectorDataTypeId :
269+
case Color3fDataTypeId :
270+
return type == SxColor;
271+
case StringVectorDataTypeId :
272+
case StringDataTypeId :
273+
return type == SxString;
274+
case FloatDataTypeId :
275+
return type == SxFloat;
276+
default :
277+
return type == SxInvalid;
278+
}
279+
}
280+
259281
void setVariables( SxParameterList parameterList, const IECore::CompoundData *points, size_t numPoints ) const
260282
{
261283
for( CompoundDataMap::const_iterator it=points->readable().begin(); it!=points->readable().end(); it++ )
262284
{
263285
ParameterInfo info = predefinedParameterInfo( it->first.value().c_str() );
264-
if( info.type != SxInvalid )
286+
if( info.type != SxInvalid && parameterTypesConsistent( info.type, it->second->typeId() ) )
265287
{
266288
setVariable( parameterList, it->first.value().c_str(), info, true, it->second.get(), numPoints );
267289
}

test/IECoreRI/SXRendererTest.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -439,18 +439,20 @@ def testPlaneShade( self ) :
439439

440440
self.assertEqual( IECore.ImageDiffOp()( imageA=image, imageB=expectedImage, maxError=0 ), IECore.BoolData( False ) )
441441

442-
def testWrongType( self ) :
443-
442+
def testVVector( self ) :
443+
444444
self.assertEqual( os.system( "shaderdl -Irsl -o test/IECoreRI/shaders/splineTest.sdl test/IECoreRI/shaders/splineTest.sl" ), 0 )
445445

446446
r = IECoreRI.SXRenderer()
447-
447+
448448
r.shader( "surface", "test/IECoreRI/shaders/splineTest.sdl", {} )
449-
449+
450450
p = self.__rectanglePoints( IECore.Box2i( IECore.V2i( 0 ), IECore.V2i( 10 ) ) )
451-
p["t"] = p["P"]
452-
453-
self.assertRaises( RuntimeError, r.shade, p )
451+
452+
# this should work, as you might want to use a V3f primvar called v (velocity) in
453+
# your shader:
454+
p["v"] = p["P"]
455+
r.shade( p )
454456

455457
def testWrongSize( self ) :
456458

@@ -951,9 +953,7 @@ def testCoordinateSystems( self ):
951953
transP = points["P"][i] * IECore.M44f.createTranslated( IECore.V3f(0,0,2) ) * IECore.M44f.createRotated( IECore.V3f(1,0,0) )
952954

953955
self.failUnless( ( shaderP - transP ).length() < 1.e-5 )
954-
955-
956-
956+
957957
def tearDown( self ) :
958958

959959
files = [

0 commit comments

Comments
 (0)