1#![allow(clippy::similar_names)]
2use super::raw::{
3 AttributeOwner, AttributeTypeInfo, CameraProjectionType, ChoiceListType, CurveType, GeoType,
4 HAPI_AssetInfo, HAPI_AttributeInfo, HAPI_AttributeInfo_Create, HAPI_BoxInfo, HAPI_CameraInfo,
5 HAPI_CameraInfo_Create, HAPI_CompositorOptions, HAPI_CompositorOptions_Create,
6 HAPI_CookOptions, HAPI_CookOptions_Create, HAPI_CurveInfo, HAPI_CurveInfo_Create, HAPI_GeoInfo,
7 HAPI_ImageFileFormat, HAPI_ImageInfo, HAPI_ImageInfo_Create, HAPI_InputCurveInfo,
8 HAPI_InputCurveInfo_Create, HAPI_NodeInfo, HAPI_ObjectInfo, HAPI_PDG_EventInfo,
9 HAPI_PDG_WorkItemInfo, HAPI_PDG_WorkItemOutputFile, HAPI_ParmChoiceInfo, HAPI_ParmInfo,
10 HAPI_PartInfo, HAPI_PartInfo_Create, HAPI_SessionInfo, HAPI_SessionInfo_Create,
11 HAPI_SessionSyncInfo, HAPI_SessionSyncInfo_Create, HAPI_SphereInfo, HAPI_ThriftServerOptions,
12 HAPI_ThriftServerOptions_Create, HAPI_TimelineOptions, HAPI_TimelineOptions_Create,
13 HAPI_Transform, HAPI_Transform_Create, HAPI_TransformEuler, HAPI_TransformEuler_Create,
14 HAPI_Viewport, HAPI_Viewport_Create, HAPI_VolumeInfo, HAPI_VolumeTileInfo,
15 HAPI_VolumeVisualInfo, ImageDataFormat, ImagePacking, InputCurveMethod,
16 InputCurveParameterization, NodeFlags, NodeType, PackedPrimInstancingMode, ParmType, PartType,
17 PdgEventType, PdgWorkItemState, Permissions, PrmScriptType, RSTOrder, RampType,
18 StatusVerbosity, StorageType, TcpPortType, ThriftSharedMemoryBufferType, VolumeType,
19 VolumeVisualType, XYZOrder,
20};
21use crate::{
22 errors::Result,
23 node::{HoudiniNode, NodeHandle},
24 parameter::ParmHandle,
25 pdg::WorkItemId,
26 session::Session,
27 stringhandle::StringHandle,
28};
29use debug_ignore::DebugIgnore;
30use pastey::paste;
31use std::ffi::{CStr, CString};
32
33macro_rules! get {
34
35 ($method:ident->$field:ident->bool) => {
36 #[inline]
37 pub fn $method(&self) -> bool {
38 self.0.$field == 1
39 }
40 };
41
42 ($method:ident->$field:ident->[handle: $hdl:ident]) => {
44 #[inline]
45 pub fn $method(&self) -> $hdl {
46 $hdl(self.0.$field)
47 }
48 };
49
50 ($self_:ident, $method:ident->$block:block->$tp:ty) => {
51 #[inline]
52 pub fn $method(&$self_) -> $tp {
53 $block
54 }
55 };
56
57 ($method:ident->$field:ident->Result<String>) => {
58 #[inline]
59 pub fn $method(&self) -> Result<String> {
60 use crate::stringhandle::StringHandle;
61 crate::stringhandle::get_string(StringHandle(self.0.$field), &self.1)
62 }
63 };
64
65 (with_session $method:ident->$field:ident->Result<String>) => {
66 #[inline]
67 pub fn $method(&self, session: &Session) -> Result<String> {
68 use crate::stringhandle::StringHandle;
69 crate::stringhandle::get_string(StringHandle(self.0.$field), session)
70 }
71 };
72
73 ($method:ident->$field:ident->Result<CString>) => {
74 #[inline]
75 pub fn $method(&self) -> Result<CString> {
76 use crate::stringhandle::StringHandle;
77 crate::stringhandle::get_cstring(StringHandle(self.0.$field), &self.1)
78 }
79 };
80
81 ($method:ident->$field:ident->$tp:ty) => {
82 #[inline]
83 pub fn $method(&self) -> $tp {
84 self.0.$field
85 }
86 };
87
88 ($method:ident->$field:ident->[$($tp:tt)*]) => {
89 get!($method->$field->[$($tp)*]);
90 };
91}
92macro_rules! wrap {
111 (_with_ $method:ident->$field:ident->bool) => {
112 paste!{
113 #[must_use]
114 pub fn [<with_ $method>](mut self, val: bool) -> Self {self.0.$field = i8::from(val); self}
115 }
116 };
117 (_with_ $method:ident->$field:ident->$tp:ty) => {
118 paste!{
119 #[must_use]
120 pub fn [<with_ $method>](mut self, val: $tp) -> Self {self.0.$field = val; self}
121 }
122 };
123 (_set_ $method:ident->$field:ident->bool) => {
124 paste!{
125 pub fn [<set_ $method>](&mut self, val: bool) {self.0.$field = i8::from(val)}
126 }
127 };
128 (_set_ $method:ident->$field:ident->$tp:ty) => {
129 paste!{
130 pub fn [<set_ $method>](&mut self, val: $tp) {self.0.$field = val}
131 }
132 };
133
134 ([get] $object:ident $method:ident->$field:ident->$($tp:tt)*) => {
136 get!($method->$field->$($tp)*);
137 };
138
139 ([get+session] $object:ident $method:ident->$field:ident->$($tp:tt)*) => {
140 get!(with_session $method->$field->$($tp)*);
141 };
142
143 ([set] $object:ident $method:ident->$field:ident->$($tp:tt)*) => {
144 $(wrap!{_set_ $method->$field->$tp})*
145 };
146
147 ([with] $object:ident $method:ident->$field:ident->$($tp:tt)*) => {
148 $(wrap!{_with_ $method->$field->$tp})*
149 };
150
151 ([get|set] $object:ident $method:ident->$field:ident->$($tp:tt)*) => {
152 get!($method->$field->$($tp)*);
153 $(wrap!{_set_ $method->$field->$tp})*
154 };
155 ([get|set|with] $object:ident $method:ident->$field:ident->$($tp:tt)*) => {
156 get!($method->$field->$($tp)*);
157 $(wrap!{_set_ $method->$field->$tp})*
158 $(wrap!{_with_ $method->$field->$tp})*
159 };
160
161 (Default $object:ident [$create_func:path=>$ffi_tp:ty]; $($rest:tt)*) => {
162 impl Default for $object {
163 fn default() -> Self {
164 #[allow(unused_unsafe)]
165 Self(unsafe { $create_func() })
166 }
167 }
168 wrap!{_impl_methods_ $object $ffi_tp $($rest)*}
169 };
170
171 (impl $object:ident=>$ffi_tp:ty; $($rest:tt)*) => {
172 wrap!{_impl_methods_ $object $ffi_tp $($rest)*}
173 };
174
175
176 (_impl_methods_ $object:ident $ffi_tp:ty
177 $([$($access:tt)*] $method:ident->$field:ident->[$($tp:tt)*]);* $(;)?
178 ) => {
179 impl $object {
180 $(wrap!([$($access)*] $object $method->$field->$($tp)*);)*
181
182 #[inline]
183 pub fn ptr(&self) -> *const $ffi_tp {
184 &raw const self.0
185 }
186 }
187 };
188}
189
190#[derive(Clone, Debug)]
193pub struct SessionInfo(pub(crate) HAPI_SessionInfo);
194
195wrap! {
196 Default SessionInfo [HAPI_SessionInfo_Create => HAPI_SessionInfo];
197 [get|set|with] connection_count->connectionCount->[i32];
198 [get|set|with] port_type->portType->[TcpPortType];
199 [get] min_port->minPort->[i32];
200 [get] max_port->maxPort->[i32];
201 [get] ports->ports->[[i32;128usize]];
202 [get] shared_memory_buffer_type->sharedMemoryBufferType->[ThriftSharedMemoryBufferType];
203 [get] shared_memory_buffer_size->sharedMemoryBufferSize->[i64];
204}
205
206impl SessionInfo {
208 pub(crate) fn set_shared_memory_buffer_type(&mut self, value: ThriftSharedMemoryBufferType) {
209 self.0.sharedMemoryBufferType = value;
210 }
211
212 pub(crate) fn set_shared_memory_buffer_size(&mut self, value: i64) {
213 self.0.sharedMemoryBufferSize = value;
214 }
215}
216
217#[derive(Clone, Debug)]
219pub struct ThriftServerOptions(pub(crate) HAPI_ThriftServerOptions);
220
221wrap! {
222 Default ThriftServerOptions [HAPI_ThriftServerOptions_Create => HAPI_ThriftServerOptions];
223 [get|set|with] auto_close->autoClose->[bool];
224 [get|set|with] timeout_ms->timeoutMs->[f32];
225 [get|set|with] verbosity->verbosity->[StatusVerbosity];
226 [get|set|with] shared_memory_buffer_type->sharedMemoryBufferType->[ThriftSharedMemoryBufferType];
227 [get|set|with] shared_memory_buffer_size->sharedMemoryBufferSize->[i64];
228}
229
230#[derive(Clone)]
231pub struct CompositorOptions(pub(crate) HAPI_CompositorOptions);
232
233wrap! {
234 Default CompositorOptions [HAPI_CompositorOptions_Create => HAPI_CompositorOptions];
235 [get|set] max_resolution_x->maximumResolutionX->[i32];
236 [get|set] max_resolution_y->maximumResolutionY->[i32];
237}
238
239#[derive(Clone)]
241pub struct ParmChoiceInfo(pub(crate) HAPI_ParmChoiceInfo, pub(crate) Session);
242
243impl std::fmt::Debug for ParmChoiceInfo {
244 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
245 use std::borrow::Cow;
246
247 let get_str = |h: i32| -> Cow<str> {
248 match crate::ffi::get_string_bytes(&self.1, StringHandle(h)) {
249 Ok(bytes) => unsafe { Cow::Owned(String::from_utf8_unchecked(bytes)) },
251 Err(_) => Cow::Borrowed("!!! Could not retrieve string"),
252 }
253 };
254
255 f.debug_struct("ParmChoiceInfo")
256 .field("label", &get_str(self.0.labelSH))
257 .field("value", &get_str(self.0.valueSH))
258 .finish()
259 }
260}
261
262impl ParmChoiceInfo {
263 get!(value->valueSH->Result<String>);
264 get!(label->labelSH->Result<String>);
265}
266
267#[derive(Debug)]
269pub struct ParmInfo(
270 pub(crate) HAPI_ParmInfo,
271 pub(crate) DebugIgnore<Session>,
272 pub(crate) Option<CString>,
273);
274
275impl ParmInfo {
276 pub(crate) fn new(inner: HAPI_ParmInfo, session: Session, name: Option<CString>) -> Self {
277 Self(inner, DebugIgnore(session), name)
278 }
279}
280
281impl ParmInfo {
282 get!(id->id->[handle: ParmHandle]);
283 get!(parent_id->parentId->[handle: ParmHandle]);
284 get!(child_index->childIndex->i32);
285 get!(parm_type->type_->ParmType);
286 get!(script_type->scriptType->PrmScriptType);
287 get!(permissions->permissions->Permissions);
288 get!(tag_count->tagCount->i32);
289 get!(size->size->i32);
290 get!(choice_count->choiceCount->i32);
291 get!(choice_list_type->choiceListType->ChoiceListType);
292 get!(has_min->hasMin->bool);
293 get!(has_max->hasMax->bool);
294 get!(has_uimin->hasUIMin->bool);
295 get!(has_uimax->hasUIMax->bool);
296 get!(min->min->f32);
297 get!(max->max->f32);
298 get!(uimin->UIMin->f32);
299 get!(uimax->UIMax->f32);
300 get!(invisible->invisible->bool);
301 get!(disabled->disabled->bool);
302 get!(spare->spare->bool);
303 get!(join_next->joinNext->bool);
304 get!(label_none->labelNone->bool);
305 get!(int_values_index->intValuesIndex->i32);
306 get!(float_values_index->floatValuesIndex->i32);
307 get!(string_values_index->stringValuesIndex->i32);
308 get!(choice_index->choiceIndex->i32);
309 get!(input_node_type->inputNodeType->NodeType);
310 get!(input_node_flag->inputNodeFlag->NodeFlags);
311 get!(is_child_of_multi_parm->isChildOfMultiParm->bool);
312 get!(instance_num->instanceNum->i32);
313 get!(instance_length->instanceLength->i32);
314 get!(instance_count->instanceCount->i32);
315 get!(instance_start_offset->instanceStartOffset->i32);
316 get!(ramp_type->rampType->RampType);
317 get!(type_info->typeInfoSH->Result<String>);
318 get!(name->nameSH->Result<String>);
319 get!(name_cstr->nameSH->Result<CString>);
320 get!(label->labelSH->Result<String>);
321 get!(template_name->templateNameSH->Result<String>);
322 get!(help->helpSH->Result<String>);
323 get!(visibility_condition->visibilityConditionSH->Result<String>);
324 get!(disabled_condition->disabledConditionSH->Result<String>);
325}
326
327pub struct NodeInfo(pub(crate) HAPI_NodeInfo, pub(crate) DebugIgnore<Session>);
330
331impl NodeInfo {
332 get!(name->nameSH->Result<String>);
333 get!(internal_path->internalNodePathSH->Result<String>);
334 get!(node_type->type_->NodeType);
335 get!(is_valid->isValid->bool);
336 get!(unique_node_id->uniqueHoudiniNodeId->i32);
337 get!(total_cook_count->totalCookCount->i32);
338 get!(child_node_count->childNodeCount->i32);
339 get!(parm_count->parmCount->i32);
340 get!(input_count->inputCount->i32);
341 get!(output_count->outputCount->i32);
342 get!(is_time_dependent->isTimeDependent->bool);
343 get!(created_post_asset_load->createdPostAssetLoad->bool);
344 get!(parm_int_value_count->parmIntValueCount->i32);
345 get!(parm_float_value_count->parmFloatValueCount->i32);
346 get!(parm_string_value_count->parmStringValueCount->i32);
347 get!(parm_choice_count->parmChoiceCount->i32);
348 get!(node_handle->id->[handle: NodeHandle]);
349 get!(parent_id->parentId->[handle: NodeHandle]);
350
351 pub(crate) fn new(session: &Session, node: NodeHandle) -> Result<Self> {
352 let session = session.clone();
353 let inner = crate::ffi::get_node_info(node, &session)?;
354 Ok(Self(inner, DebugIgnore(session)))
355 }
356}
357
358impl std::fmt::Debug for NodeInfo {
359 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
360 let err = "Error in Debug impl";
361 f.debug_struct("NodeInfo")
362 .field("name", &self.name().as_deref().unwrap_or(err))
363 .field(
364 "internal_path",
365 &self.internal_path().as_deref().unwrap_or(err),
366 )
367 .field("type", &self.node_type())
368 .field("is_valid", &self.is_valid())
369 .field("time_dependent", &self.is_time_dependent())
370 .field("total_cook_count", &self.total_cook_count())
371 .field("parm_count", &self.parm_count())
372 .field("child_count", &self.child_node_count())
373 .field("input_count", &self.input_count())
374 .field("output_count", &self.output_count())
375 .finish()
376 }
377}
378
379#[derive(Debug, Clone)]
381pub struct CookOptions(pub(crate) HAPI_CookOptions);
382
383wrap!(
384 Default CookOptions [HAPI_CookOptions_Create => HAPI_CookOptions];
385 [get|set|with] split_geo_by_group->splitGeosByGroup->[bool];
386 [get|set|with] split_geos_by_attribute->splitGeosByAttribute->[bool];
387 [get|set|with] max_vertices_per_primitive->maxVerticesPerPrimitive->[i32];
388 [get|set|with] refine_curve_to_linear->refineCurveToLinear->[bool];
389 [get|set|with] curve_refine_lod->curveRefineLOD->[f32];
390 [get|set|with] clear_errors_and_warnings->clearErrorsAndWarnings->[bool];
391 [get|set|with] cook_templated_geos->cookTemplatedGeos->[bool];
392 [get|set|with] split_points_by_vertex_attributes->splitPointsByVertexAttributes->[bool];
393 [get|set|with] handle_box_part_types->handleBoxPartTypes->[bool];
394 [get|set|with] handle_sphere_part_types->handleSpherePartTypes->[bool];
395 [get|set|with] check_part_changes->checkPartChanges->[bool];
396 [get|set|with] cache_mesh_topology->cacheMeshTopology->[bool];
397 [get|set|with] prefer_output_nodes->preferOutputNodes->[bool];
398 [get|set|with] packed_prim_instancing_mode->packedPrimInstancingMode->[PackedPrimInstancingMode];
399 [get+session] split_attr->splitAttrSH->[Result<String>];
400);
401
402#[derive(Debug, Clone)]
403pub struct AttributeInfo(pub(crate) HAPI_AttributeInfo);
404
405impl Default for AttributeInfo {
406 fn default() -> Self {
407 let mut inner = unsafe { HAPI_AttributeInfo_Create() };
408 inner.totalArrayElements = 0;
410 Self(inner)
411 }
412}
413wrap! {
414 _impl_methods_ AttributeInfo HAPI_AttributeInfo[get]exists->exists->[bool];
415 [get]original_owner->originalOwner->[AttributeOwner];
416 [get|set|with]total_array_elements->totalArrayElements->[i64];
417 [get|set|with]owner->owner->[AttributeOwner];
418 [get|set|with]storage->storage->[StorageType];
419 [get|set|with]tuple_size->tupleSize->[i32];
420 [get|set|with]type_info->typeInfo->[AttributeTypeInfo];
421 [get|set|with]count->count->[i32];
422}
423
424impl AttributeInfo {
425 pub(crate) fn new(
426 node: &HoudiniNode,
427 part_id: i32,
428 owner: AttributeOwner,
429 name: &CStr,
430 ) -> Result<Self> {
431 Ok(Self(crate::ffi::get_attribute_info(
432 node, part_id, owner, name,
433 )?))
434 }
435}
436
437#[derive(Debug)]
439pub struct AssetInfo(pub(crate) HAPI_AssetInfo, pub DebugIgnore<Session>);
440
441impl AssetInfo {
442 get!(node_id->nodeId->[handle: NodeHandle]);
443 get!(object_node_id->objectNodeId->[handle: NodeHandle]);
444 get!(has_ever_cooked->hasEverCooked->bool);
445 get!(have_objects_changed->haveObjectsChanged->bool);
446 get!(have_materials_changed->haveMaterialsChanged->bool);
447 get!(object_count->objectCount->i32);
448 get!(handle_count->handleCount->i32);
449 get!(transform_input_count->transformInputCount->i32);
450 get!(geo_input_count->geoInputCount->i32);
451 get!(geo_output_count->geoOutputCount->i32);
452 get!(name->nameSH->Result<String>);
453 get!(label->labelSH->Result<String>);
454 get!(file_path->filePathSH->Result<String>);
455 get!(version->versionSH->Result<String>);
456 get!(full_op_name->fullOpNameSH->Result<String>);
457 get!(help_text->helpTextSH->Result<String>);
458 get!(help_url->helpURLSH->Result<String>);
459}
460
461#[derive(Debug)]
463pub struct ObjectInfo<'session>(
464 pub(crate) HAPI_ObjectInfo,
465 pub DebugIgnore<&'session Session>,
466);
467
468impl ObjectInfo<'_> {
469 get!(name->nameSH->Result<String>);
470 get!(object_instance_path->objectInstancePathSH->Result<String>);
471 get!(has_transform_changed->hasTransformChanged->bool);
472 get!(have_geos_changed->haveGeosChanged->bool);
473 get!(is_visible->isVisible->bool);
474 get!(is_instancer->isInstancer->bool);
475 get!(is_instanced->isInstanced->bool);
476 get!(geo_count->geoCount->bool);
477 get!(node_id->nodeId->[handle: NodeHandle]);
478 get!(object_to_instance_id->objectToInstanceId->[handle: NodeHandle]);
479 pub fn to_node(&self) -> Result<HoudiniNode> {
480 self.node_id().to_node(&self.1)
481 }
482}
483
484#[derive(Debug, Clone)]
485pub struct GeoInfo(pub(crate) HAPI_GeoInfo);
487
488impl<'s> GeoInfo {
489 get!(geo_type->type_->GeoType);
490 get!(with_session name->nameSH->Result<String>);
491 get!(node_id->nodeId->[handle: NodeHandle]);
492 get!(is_editable->isEditable->bool);
493 get!(is_templated->isTemplated->bool);
494 get!(is_display_geo->isDisplayGeo->bool);
495 get!(has_geo_changed->hasGeoChanged->bool);
496 get!(has_material_changed->hasMaterialChanged->bool);
497 get!(edge_group_count->edgeGroupCount->i32);
498 get!(point_group_count->pointGroupCount->i32);
499 get!(primitive_group_count->primitiveGroupCount->i32);
500 get!(part_count->partCount->i32);
501
502 pub fn from_node(node: &'s HoudiniNode) -> Result<Self> {
503 GeoInfo::from_handle(node.handle, &node.session)
504 }
505 pub fn from_handle(handle: NodeHandle, session: &'s Session) -> Result<GeoInfo> {
506 crate::ffi::get_geo_info(session, handle).map(GeoInfo)
507 }
508}
509
510#[derive(Debug)]
511pub struct PartInfo(pub(crate) HAPI_PartInfo);
512
513wrap!(
514 Default PartInfo [HAPI_PartInfo_Create => HAPI_PartInfo];
515 [get] part_id->id->[i32];
516 [get] attribute_counts->attributeCounts->[[i32; 4]];
517 [get] has_changed->hasChanged->[bool];
518 [get] is_instanced->isInstanced->[bool];
519 [get+session] name->nameSH->[Result<String>];
520 [get|set|with] part_type->type_->[PartType];
521 [get|set|with] face_count->faceCount->[i32];
522 [get|set|with] point_count->pointCount->[i32];
523 [get|set|with] vertex_count->vertexCount->[i32];
524 [get|set|with] instance_count->instanceCount->[i32];
525 [get|set|with] instanced_part_count->instancedPartCount->[i32];
526);
527
528#[derive(Debug, Clone)]
529pub struct TimelineOptions(pub(crate) HAPI_TimelineOptions);
530
531wrap!(
532 Default TimelineOptions [HAPI_TimelineOptions_Create => HAPI_TimelineOptions];
533 [get|set|with] fps->fps->[f64];
534 [get|set|with] start_time->startTime->[f64];
535 [get|set|with] end_time->endTime->[f64];
536);
537
538#[derive(Debug, Clone)]
539pub struct CurveInfo(pub(crate) HAPI_CurveInfo);
540
541wrap!(
542 Default CurveInfo [HAPI_CurveInfo_Create => HAPI_CurveInfo];
543 [get|set|with] curve_type->curveType->[CurveType];
544 [get|set|with] curve_count->curveCount->[i32];
545 [get|set|with] vertex_count->vertexCount->[i32];
546 [get|set|with] knot_count->knotCount->[i32];
547 [get|set|with] periodic->isPeriodic->[bool];
548 [get|set|with] rational->isRational->[bool];
549 [get|set|with] closed->isClosed->[bool];
550 [get|set|with] has_knots->hasKnots->[bool];
551 [get|set|with] order->order->[i32];
552);
553
554#[derive(Debug, Clone)]
555pub struct Viewport(pub(crate) HAPI_Viewport);
556
557wrap!(
558 Default Viewport [HAPI_Viewport_Create => HAPI_Viewport];
559 [get|set|with] position->position->[[f32; 3]];
560 [get|set|with] rotation->rotationQuaternion->[[f32; 4]];
561 [get|set|with] offset->offset->[f32];
562);
563
564#[derive(Debug, Clone)]
565pub struct Transform(pub(crate) HAPI_Transform);
567
568wrap!(
569 Default Transform [HAPI_Transform_Create => HAPI_Transform];
570 [get|set|with] position->position->[[f32;3]];
571 [get|set|with] rotation->rotationQuaternion->[[f32;4]];
572 [get|set|with] scale->scale->[[f32;3]];
573 [get|set|with] shear->shear->[[f32;3]];
574 [get|set|with] rst_order->rstOrder->[RSTOrder];
575);
576
577impl Transform {
578 pub fn from_matrix(session: &Session, matrix: &[f32; 16], rst_order: RSTOrder) -> Result<Self> {
579 crate::ffi::convert_matrix_to_quat(session, matrix, rst_order).map(Transform)
580 }
581
582 pub fn convert_to_matrix(&self, session: &Session) -> Result<[f32; 16]> {
583 crate::ffi::convert_transform_quat_to_matrix(session, &self.0)
584 }
585}
586
587#[derive(Debug, Clone)]
588pub struct TransformEuler(pub(crate) HAPI_TransformEuler);
590
591wrap!(
592 Default TransformEuler [HAPI_TransformEuler_Create => HAPI_TransformEuler];
593 [get|set|with] position->position->[[f32;3]];
594 [get|set|with] rotation->rotationEuler->[[f32;3]];
595 [get|set|with] scale->scale->[[f32;3]];
596 [get|set|with] shear->shear->[[f32;3]];
597 [get|set|with] roation_order->rotationOrder->[XYZOrder];
598 [get|set|with] rst_order->rstOrder->[RSTOrder];
599);
600
601impl TransformEuler {
602 pub fn convert_transform(
603 &self,
604 session: &Session,
605 rst_order: RSTOrder,
606 rot_order: XYZOrder,
607 ) -> Result<Self> {
608 crate::ffi::convert_transform(session, &self.0, rst_order, rot_order).map(TransformEuler)
609 }
610
611 pub fn from_matrix(
612 session: &Session,
613 matrix: &[f32; 16],
614 rst_order: RSTOrder,
615 rot_order: XYZOrder,
616 ) -> Result<Self> {
617 crate::ffi::convert_matrix_to_euler(session, matrix, rst_order, rot_order)
618 .map(TransformEuler)
619 }
620
621 pub fn convert_to_matrix(&self, session: &Session) -> Result<[f32; 16]> {
622 crate::ffi::convert_transform_euler_to_matrix(session, &self.0)
623 }
624}
625
626#[derive(Debug, Clone)]
627pub struct SessionSyncInfo(pub(crate) HAPI_SessionSyncInfo);
628
629wrap!(
630 Default SessionSyncInfo [HAPI_SessionSyncInfo_Create => HAPI_SessionSyncInfo];
631 [get|set|with] cook_using_houdini_time->cookUsingHoudiniTime->[bool];
632 [get|set|with] sync_viewport->syncViewport->[bool];
633);
634
635#[derive(Debug, Clone)]
636pub struct BoxInfo(pub(crate) HAPI_BoxInfo);
637
638fn create_box_info() -> HAPI_BoxInfo {
639 HAPI_BoxInfo {
640 center: Default::default(),
641 size: Default::default(),
642 rotation: Default::default(),
643 }
644}
645
646wrap!(
647 Default BoxInfo [create_box_info => HAPI_BoxInfo];
648 [get|set|with] center->center->[[f32;3]];
649 [get|set|with] rotation->rotation->[[f32;3]];
650 [get|set|with] size->size->[[f32;3]];
651);
652
653#[derive(Debug, Clone)]
654pub struct SphereInfo(pub(crate) HAPI_SphereInfo);
655
656fn create_sphere_info() -> HAPI_SphereInfo {
657 HAPI_SphereInfo {
658 center: Default::default(),
659 radius: 0.0,
660 }
661}
662
663wrap!(
664 Default SphereInfo [create_sphere_info => HAPI_SphereInfo];
665 [get|set|with] center->center->[[f32;3]];
666 [get|set|with] radius->radius->[f32];
667);
668
669#[derive(Debug, Clone)]
670pub struct CameraInfo(pub(crate) HAPI_CameraInfo);
671
672wrap!(
673 Default CameraInfo [HAPI_CameraInfo_Create => HAPI_CameraInfo];
674 [get|set|with] focal->focal->[f64];
675 [get|set|with] aperture->aperture->[f64];
676 [get|set|with] pixel_aspect->pixelAspect->[f64];
677 [get|set|with] focus_distance->focusDistance->[f64];
678 [get|set|with] f_stop->fStop->[f64];
679 [get|set|with] imaging_distance->imagingDistance->[f64];
680 [get|set|with] res_x->resX->[i64];
681 [get|set|with] res_y->resY->[i64];
682 [get|set|with] crop_x->cropX->[[f64;2]];
683 [get|set|with] crop_y->cropY->[[f64;2]];
684 [get|set|with] win_x->winX->[[f64;2]];
685 [get|set|with] win_y->winY->[[f64;2]];
686 [get|set|with] clip_near->clipNear->[f64];
687 [get|set|with] clip_far->clipFar->[f64];
688 [get|set|with] shutter_open->shutterOpen->[f64];
689 [get|set|with] shutter_close->shutterClose->[f64];
690 [get|set|with] ortho_zoom->orthoZoom->[f64];
691 [get|set|with] guide_scale->guideScale->[f64];
692 [get|set|with] projection->projection->[CameraProjectionType];
693);
694
695#[repr(C)]
696#[derive(Debug, Clone)]
697pub struct ImageInfo(pub(crate) HAPI_ImageInfo);
698
699wrap!(
700 Default ImageInfo [HAPI_ImageInfo_Create => HAPI_ImageInfo];
701 [get|set|with] x_res->xRes->[i32];
702 [get|set|with] y_res->yRes->[i32];
703 [get|set|with] gamma->gamma->[f64];
704 [get|set|with] data_format->dataFormat->[ImageDataFormat];
705 [get|set|with] interleaved->interleaved->[bool];
706 [get|set|with] packing->packing->[ImagePacking];
707 [get+session] image_format->imageFileFormatNameSH->[Result<String>];
708);
709
710#[repr(C)]
711#[derive(Debug, Clone)]
712pub struct KeyFrame {
714 pub time: f32,
715 pub value: f32,
716 pub in_tangent: f32,
717 pub out_tangent: f32,
718}
719
720#[derive(Debug, Clone)]
721pub struct ImageFileFormat<'a>(
722 pub(crate) HAPI_ImageFileFormat,
723 pub(crate) DebugIgnore<&'a Session>,
724);
725
726impl ImageFileFormat<'_> {
727 get!(name->nameSH->Result<String>);
728 get!(description->descriptionSH->Result<String>);
729 get!(extension->defaultExtensionSH->Result<String>);
730}
731
732#[derive(Debug, Clone)]
733pub struct VolumeInfo(pub(crate) HAPI_VolumeInfo);
734
735wrap!(
736 impl VolumeInfo => HAPI_VolumeInfo;
737 [get+session] name->nameSH->[Result<String>];
738 [get] volume_type->type_->[VolumeType];
739 [get|set|with] x_length->xLength->[i32];
740 [get|set|with] y_length->yLength->[i32];
741 [get|set|with] z_length->zLength->[i32];
742 [get|set|with] min_x->minX->[i32];
743 [get|set|with] min_y->minY->[i32];
744 [get|set|with] min_z->minZ->[i32];
745 [get|set|with] tuple_size->tupleSize->[i32];
746 [get|set|with] storage->storage->[StorageType];
747 [get|set|with] tile_size->tileSize->[i32];
748 [get|set|with] has_taper->hasTaper->[bool];
749 [get|set|with] x_taper->xTaper->[f32];
750 [get|set|with] y_taper->yTaper->[f32];
751);
752
753impl VolumeInfo {
754 fn transform(&self) -> Transform {
755 Transform(self.0.transform)
756 }
757 fn set_transform(&mut self, transform: &Transform) {
758 self.0.transform = transform.0;
759 }
760 fn with_transform(mut self, transform: &Transform) -> Self {
761 self.0.transform = transform.0;
762 self
763 }
764}
765
766#[derive(Debug, Clone)]
767pub struct VolumeTileInfo(pub(crate) HAPI_VolumeTileInfo);
768
769wrap!(
770 impl VolumeTileInfo => HAPI_VolumeTileInfo;
771 [get|set|with] min_x->minX->[i32];
772 [get|set|with] min_y->minY->[i32];
773 [get|set|with] min_z->minZ->[i32];
774 [get] is_valid->isValid->[bool];
775);
776
777#[derive(Debug, Clone)]
778pub struct VolumeVisualInfo(pub(crate) HAPI_VolumeVisualInfo);
779
780wrap!(
781 impl VolumeVisualInfo => HAPI_VolumeVisualInfo;
782 [get|set|with] visual_type->type_->[VolumeVisualType];
783 [get|set|with] iso->iso->[f32];
784 [get|set|with] density->density->[f32];
785);
786
787#[derive(Debug, Clone)]
788pub struct InputCurveInfo(pub(crate) HAPI_InputCurveInfo);
789
790wrap!(
791 Default InputCurveInfo [HAPI_InputCurveInfo_Create => HAPI_InputCurveInfo];
792 [get|set|with] curve_type->curveType->[CurveType];
793 [get|set|with] order->order->[i32];
794 [get|set|with] closed->closed->[bool];
795 [get|set|with] reverse->reverse->[bool];
796 [get|set|with] input_method->inputMethod->[InputCurveMethod];
797 [get|set|with] breakpoint_parameterization->breakpointParameterization->[InputCurveParameterization];
798);
799
800#[derive(Debug, Copy, Clone)]
801pub struct PDGEventInfo(pub(crate) HAPI_PDG_EventInfo);
802
803impl PDGEventInfo {
804 get!(node_id->nodeId->[handle: NodeHandle]);
805 get!(workitem_id->workItemId->[handle: WorkItemId]);
806 get!(dependency_id->dependencyId->i32);
807 get!(with_session message->msgSH->Result<String>);
808 pub fn current_state(&self) -> PdgWorkItemState {
809 unsafe { std::mem::transmute::<i32, PdgWorkItemState>(self.0.currentState) }
810 }
811 pub fn last_state(&self) -> PdgWorkItemState {
812 unsafe { std::mem::transmute::<i32, PdgWorkItemState>(self.0.lastState) }
813 }
814 pub fn event_type(&self) -> PdgEventType {
815 unsafe { std::mem::transmute::<i32, PdgEventType>(self.0.eventType) }
816 }
817}
818
819#[derive(Debug)]
820pub struct PDGWorkItemOutputFile<'session>(
821 pub(crate) HAPI_PDG_WorkItemOutputFile,
822 pub(crate) DebugIgnore<&'session Session>,
823);
824
825impl PDGWorkItemOutputFile<'_> {
826 get!(path->filePathSH->Result<String>);
827 get!(tag->tagSH->Result<String>);
828 get!(sha->hash->i64);
829}
830
831pub struct PDGWorkItemInfo(pub(crate) HAPI_PDG_WorkItemInfo);
832
833wrap! {
834 impl PDGWorkItemInfo => HAPI_PDG_WorkItemInfo;
835 [get] index->index->[i32];
836 [get] output_file_count->outputFileCount->[i32];
837 [get+session] name->nameSH->[Result<String>];
838}