Skip to content

Commit

Permalink
Display: Fix OCS mapping with scaled block
Browse files Browse the repository at this point in the history
  • Loading branch information
deranen committed Jun 19, 2024
1 parent dd57230 commit aab9f25
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 4 deletions.
2 changes: 1 addition & 1 deletion make_rhino.bat
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ if "%BUILDING%" == "Yes" (
-DWITH_CYCLES_USD=OFF ^
-DWITH_CYCLES_HYDRA_RENDER_DELEGATE=OFF ^
-DWITH_CYCLES_CUDA_BINARIES=OFF ^
-DWITH_CYCLES_DEVICE_OPTIX=ON ^
-DWITH_CYCLES_DEVICE_OPTIX=OFF ^
%BUILD_CUDA_CMD% ^
%BUILD_CUDABIN_CMD% ^
%BUILD_ONEAPI_CMD% ^
Expand Down
4 changes: 3 additions & 1 deletion src/ccycles/object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,9 @@ static void _cycles_scene_object_set_transform(ccl::Session* session_id, ccl::Ob
object->set_tfm(mat);
break;
case 1:
object->set_ocs_frame(transform_inverse(mat));
ccl::Transform ocs_inverse = transform_inverse(mat);
object->set_ocs_frame(ocs_inverse);
object->set_ocs_frame_normal(transform_transposed_inverse(ocs_inverse));
object->set_use_ocs_frame(mat != ccl::transform_identity());
break;
}
Expand Down
10 changes: 8 additions & 2 deletions src/kernel/svm/tex_coord.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ ccl_device_inline void wcs_box_coord(KernelGlobals kg, ccl_private ShaderData *s
if (sd->object != OBJECT_NONE && kernel_data_fetch(objects, sd->object).use_ocs_frame) {
Transform tfm = kernel_data_fetch(objects, sd->object).ocs_frame;
*data = transform_point(&tfm, *data);

tfm = kernel_data_fetch(objects, sd->object).ocs_frame_normal;
N = transform_direction(&tfm, N);
}

int side0 = 0;
Expand Down Expand Up @@ -554,8 +557,6 @@ ccl_device_noinline int svm_rhino_node_tex_coord(KernelGlobals kg,
data = sd->P;
if (sd->object != OBJECT_NONE && kernel_data_fetch(objects, sd->object).use_ocs_frame) {
has_ocs = true;
Transform tfm = kernel_data_fetch(objects, sd->object).ocs_frame;
data = transform_point(&tfm, data);
}
if (node.w == 0) {
if (sd->object != OBJECT_NONE) {
Expand All @@ -574,6 +575,11 @@ ccl_device_noinline int svm_rhino_node_tex_coord(KernelGlobals kg,
tfm = transform_clear_scale(&tfm);
data = transform_point(&tfm, data);
}
if (has_ocs)
{
Transform tfm = kernel_data_fetch(objects, sd->object).ocs_frame;
data = transform_point(&tfm, data);
}
break;
}
case NODE_TEXCO_NORMAL: {
Expand Down
1 change: 1 addition & 0 deletions src/kernel/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -1298,6 +1298,7 @@ typedef struct KernelObject {
/* Rhino properties */
bool use_ocs_frame;
Transform ocs_frame; /* OCS frame for controlling WCS and WCS Box. */
Transform ocs_frame_normal; /* OCS frame for controlling WCS and WCS Box normals. */
/* Rhino properties end */

} KernelObject;
Expand Down
2 changes: 2 additions & 0 deletions src/scene/object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ NODE_DEFINE(Object)

SOCKET_BOOLEAN(use_ocs_frame, "Use OCS Frame", false);
SOCKET_TRANSFORM(ocs_frame, "OCS Frame", transform_identity());
SOCKET_TRANSFORM(ocs_frame_normal, "OCS Frame Normal", transform_identity());

return type;
}
Expand Down Expand Up @@ -443,6 +444,7 @@ void ObjectManager::device_update_object_transform(UpdateObjectTransformState *s
kobject.tfm = tfm;
kobject.itfm = itfm;
kobject.ocs_frame = ob->ocs_frame;
kobject.ocs_frame_normal = ob->ocs_frame_normal;
kobject.use_ocs_frame = ob->use_ocs_frame;
kobject.volume_density = object_volume_density(tfm, geom);
kobject.color[0] = color.x;
Expand Down
1 change: 1 addition & 0 deletions src/scene/object.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ class Object : public Node {

NODE_SOCKET_API(bool, use_ocs_frame)
NODE_SOCKET_API(Transform, ocs_frame) /* OCS frame for controlling WCS and WCS Box. */
NODE_SOCKET_API(Transform, ocs_frame_normal) /* OCS frame for controlling WCS and WCS Box normal. */

/* Set during device update. */
bool intersects_volume;
Expand Down

0 comments on commit aab9f25

Please sign in to comment.