HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
HUSD_ApexScene.h
Go to the documentation of this file.
1 /*
2  * Copyright 2025 Side Effects Software Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15 */
16 
17 #ifndef __HUSD_ApexScene_h__
18 #define __HUSD_ApexScene_h__
19 
20 #include "HUSD_API.h"
21 
22 #include "HUSD_Path.h"
23 
24 #include <SYS/SYS_Types.h>
25 #include <UT/UT_Array.h>
26 #include <UT/UT_NonCopyable.h>
27 #include <UT/UT_Set.h>
28 #include <UT/UT_StringHolder.h>
29 #include <UT/UT_StringMap.h>
30 #include <UT/UT_UniquePtr.h>
31 
32 class APEXA_SceneInvoke;
34 class GU_DetailHandle;
35 class HUSD_AutoAnyLock;
36 class HUSD_AutoWriteLock;
37 class HUSD_FindPrims;
38 
39 enum class HUSD_ApexShapeType : uint8;
40 
41 /// Stores an APEX scene loaded from USD (a HoudiniApexScene prim), along with
42 /// information about the USD primitives bound to APEX scene outputs.
43 /// This can be safely cached between LOP cooks to avoid rebuilding APEX scenes
44 /// unless the input stage has changed.
46 {
47 public:
50 
52 
53  /// Options for how to convert USD prims to geometry for APEX rig inputs.
55  {
56  /// If non-empty, adds a prim attribute with the source USD prim's path.
58  };
59 
60  /// Assembles APEX scenes from the specified list of HoudiniApexScene
61  /// prims.
62  /// This performs validation checks to ensure that e.g. a prim isn't driven
63  /// by the output of more than one scene.
64  static bool loadScenes(
65  const HUSD_AutoAnyLock &read_lock,
66  const HUSD_FindPrims &find_prims,
67  const GeoImportOptions &import_options,
68  UT_Array<HUSD_ApexScene> &scenes);
69 
70  /// Assemble the input geometry for an APEX scene from the specified
71  /// HoudiniApexScene prim.
73  const HUSD_AutoAnyLock &read_lock,
74  const HUSD_Path &scene_path,
75  const GeoImportOptions &import_options);
76 
77  /// Evaluates the scene at the specified list of samples, and updates any
78  /// prims bound to a scene output.
79  bool evaluateOutputs(
80  HUSD_AutoWriteLock &write_lock,
82  const UT_StringRef &xform_description,
83  bool use_xform_common_api);
84 
86  {
87  exint mySceneOutputIdx = -1;
89  HUSD_ApexShapeType myShapeType;
90  };
91 
93  {
94  exint mySceneOutputIdx = -1;
97  };
98 
99 private:
100  /// Loads the APEX scene from packed folders.
101  bool loadFromGeometry(const GU_ConstDetailHandle &scene_gdh);
102 
104  UT_Array<ShapeOutputInfo> myShapeOutputs;
105  UT_Array<XformOutputInfo> myXformOutputs;
106 
107  /// Map from xforming prim paths to their unique index from 0-N.
108  UT_Map<HUSD_Path, exint> myXformingPrimIndex;
109  /// Index of the closest parent xforming prim, or -1.
110  UT_Array<exint> myXformingPrimParents;
111 };
112 
113 #endif
bool evaluateOutputs(HUSD_AutoWriteLock &write_lock, const UT_SortedSet< fpreal > &samples, const UT_StringRef &xform_description, bool use_xform_common_api)
*get result *(waiting if necessary)*A common idiom is to fire a bunch of sub tasks at the and then *wait for them to all complete We provide a helper class
Definition: thread.h:632
int64 exint
Definition: SYS_Types.h:125
#define HUSD_API
Definition: HUSD_API.h:31
std::unique_ptr< T, Deleter > UT_UniquePtr
A smart pointer for unique ownership of dynamically allocated objects.
Definition: UT_UniquePtr.h:39
unsigned char uint8
Definition: SYS_Types.h:36
#define UT_NON_COPYABLE(CLASS)
Define deleted copy constructor and assignment operator inside a class.
static bool loadScenes(const HUSD_AutoAnyLock &read_lock, const HUSD_FindPrims &find_prims, const GeoImportOptions &import_options, UT_Array< HUSD_ApexScene > &scenes)
GLsizei samples
Definition: glcorearb.h:1298
static GU_DetailHandle loadSceneGeometry(const HUSD_AutoAnyLock &read_lock, const HUSD_Path &scene_path, const GeoImportOptions &import_options)
UT_StringHolder myPathAttrib
If non-empty, adds a prim attribute with the source USD prim's path.
HUSD_ApexShapeType myShapeType
Options for how to convert USD prims to geometry for APEX rig inputs.