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 /// Stores an APEX scene loaded from USD (a HoudiniApexScene prim), along with
40 /// information about the USD primitives bound to APEX scene outputs.
41 /// This can be safely cached between LOP cooks to avoid rebuilding APEX scenes
42 /// unless the input stage has changed.
44 {
45 public:
47  ~HUSD_ApexScene();
48 
50 
51  /// Options for how to convert USD prims to geometry for APEX rig inputs.
53  {
54  /// If non-empty, adds a prim attribute with the source USD prim's path.
56  };
57 
58  /// Assembles APEX scenes from the specified list of HoudiniApexScene
59  /// prims.
60  /// This performs validation checks to ensure that e.g. a prim isn't driven
61  /// by the output of more than one scene.
62  static bool loadScenes(
63  const HUSD_AutoAnyLock &read_lock,
64  const HUSD_FindPrims &find_prims,
65  const GeoImportOptions &import_options,
66  UT_Array<HUSD_ApexScene> &scenes);
67 
68  /// Assemble the input geometry for an APEX scene from the specified
69  /// HoudiniApexScene prim.
70  static GU_DetailHandle loadSceneGeometry(
71  const HUSD_AutoAnyLock &read_lock,
72  const HUSD_Path &scene_path,
73  const GeoImportOptions &import_options);
74 
75  /// Evaluates the scene at the specified list of samples, and updates any
76  /// prims bound to a scene output.
77  bool evaluateOutputs(
78  HUSD_AutoWriteLock &write_lock,
80  const UT_StringRef &xform_description,
81  bool use_xform_common_api);
82 
83  struct ShapeOutputInfo;
84  struct XformOutputInfo;
85 
86 private:
87  /// Loads the APEX scene from packed folders.
88  bool loadFromGeometry(const GU_ConstDetailHandle &scene_gdh);
89 
91  UT_Array<ShapeOutputInfo> myShapeOutputs;
92  UT_Array<XformOutputInfo> myXformOutputs;
93 
94  /// Map from xforming prim paths to their unique index from 0-N.
95  UT_Map<HUSD_Path, exint> myXformingPrimIndex;
96  /// Index of the closest parent xforming prim, or -1.
97  UT_Array<exint> myXformingPrimParents;
98 };
99 
100 #endif
#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
#define UT_NON_COPYABLE(CLASS)
Define deleted copy constructor and assignment operator inside a class.
GLsizei samples
Definition: glcorearb.h:1298
UT_StringHolder myPathAttrib
If non-empty, adds a prim attribute with the source USD prim's path.
Options for how to convert USD prims to geometry for APEX rig inputs.