Skip to content

Commit db18399

Browse files
authored
ShadingSystem::convert_value, allow float[3] <--> triple conversion. (#754)
This utility is used by renderers for getattribute and other renderer-to-OSL data copying, and is meant to facilitate the obvious set of copy conversions between slightly mismatched yet sensible types. Adding a clause that lets you retrieve a triple (point, color, etc.) even if it was declared on the renderer side as float[3], and vice versa.
1 parent 45a4d78 commit db18399

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

src/liboslexec/shadingsys.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -473,6 +473,7 @@ ShadingSystem::optimize_group (ShaderGroup *group,
473473

474474

475475
static TypeDesc TypeFloatArray2 (TypeDesc::FLOAT, 2);
476+
static TypeDesc TypeFloatArray3 (TypeDesc::FLOAT, 3);
476477

477478

478479

@@ -534,6 +535,14 @@ ShadingSystem::convert_value (void *dst, TypeDesc dsttype,
534535
return false; // Unsupported conversion
535536
}
536537

538+
// float[3] -> triple
539+
if ((srctype == TypeFloatArray3 && equivalent(dsttype, TypeDesc::TypePoint)) ||
540+
(dsttype == TypeFloatArray3 && equivalent(srctype, TypeDesc::TypePoint))) {
541+
if (dst && src)
542+
memcpy (dst, src, dsttype.size());
543+
return true;
544+
}
545+
537546
// float[2] -> triple
538547
if (srctype == TypeFloatArray2 && equivalent(dsttype, TypeDesc::TypePoint)) {
539548
if (dst && src) {

0 commit comments

Comments
 (0)