@@ -54,25 +54,23 @@ class Application : public BaseApplication
5454 m = manipulator,
5555 tf = tfeditor,
5656 core = core]() {
57- auto colorArray = core->tsd .ctx .createArray (ANARI_FLOAT32_VEC3, 256 );
58- auto opacityArray = core->tsd .ctx .createArray (ANARI_FLOAT32, 256 );
57+ auto colorMapArray = core->tsd .ctx .createArray (ANARI_FLOAT32_VEC4, 256 );
5958
6059 tsd::VolumeRef volume;
6160
6261 if (!g_filename.empty ()) {
6362 volume = tsd::import_volume (
64- core->tsd .ctx , g_filename.c_str (), colorArray, opacityArray );
63+ core->tsd .ctx , g_filename.c_str (), colorMapArray );
6564 }
6665
6766 if (!volume) {
6867 if (!g_filename.empty ())
6968 tsd::logWarning (" unable to load volume from file, using placeholder" );
7069
71- auto tx1 =
72- core->tsd .ctx .insertChildTransformNode (core-> tsd . ctx . defaultLayer ()->root ());
70+ auto tx1 = core-> tsd . ctx . insertChildTransformNode (
71+ core->tsd .ctx .defaultLayer ()->root ());
7372
74- volume = tsd::generate_noiseVolume (
75- core->tsd .ctx , tx1, colorArray, opacityArray);
73+ volume = tsd::generate_noiseVolume (core->tsd .ctx , tx1, colorMapArray);
7674 }
7775
7876 core->tsd .selectedObject = volume.data ();
@@ -90,7 +88,8 @@ class Application : public BaseApplication
9088 light->setName (" mainLight" );
9189 light->setParameter (" direction" , tsd::float2 (0 .f , 240 .f ));
9290
93- core->tsd .ctx .defaultLayer ()->insert_first_child (core->tsd .ctx .defaultLayer ()->root (),
91+ core->tsd .ctx .defaultLayer ()->insert_first_child (
92+ core->tsd .ctx .defaultLayer ()->root (),
9493 tsd::utility::Any (ANARI_LIGHT, light.index ()));
9594 }
9695
@@ -102,18 +101,9 @@ class Application : public BaseApplication
102101
103102 tf->setUpdateCallback ([=](const tsd::float2 &valueRange,
104103 const std::vector<tsd::float4> &co) mutable {
105- auto *colors = colorArray->mapAs <tsd::float3>();
106- auto *opacities = opacityArray->mapAs <float >();
107- std::transform (co.begin (), co.end (), colors, [](const tsd::float4 &v) {
108- return tsd::float3 (v.x , v.y , v.z );
109- });
110- std::transform (
111- co.begin (), co.end (), opacities, [](const tsd::float4 &v) {
112- return v.w ;
113- });
114- colorArray->unmap ();
115- opacityArray->unmap ();
116-
104+ auto *colorMap = colorMapArray->mapAs <tsd::float4>();
105+ std::copy (co.begin (), co.end (), colorMap);
106+ colorMapArray->unmap ();
117107 volume->setParameter (" valueRange" , ANARI_FLOAT32_BOX1, &valueRange);
118108 });
119109 });
0 commit comments