Skip to content

Commit 50eea04

Browse files
adskWanglGitHub Enterprise
authored andcommitted
Release v25.08 Beta
* Add Metal backend support for macOS. * Update dependency and build system to support cross-platform development. * Fix usdview crash [Part2]: update slang. * Fix crash when loading AutodeskTelescope using usdview [Part1]. * Fix out-of-bound crashes * Fix normal_image MaterialX definitions. * Fix warning when getting data from no empty VtValues. * Fix build error on latest VS2022. * Fix runtime folder plugin files. * Fix Loading Large Size Image Crash with HgiRenderer. * Fix Image Resolver Plugin.
1 parent f0f9209 commit 50eea04

File tree

433 files changed

+12782
-1556
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

433 files changed

+12782
-1556
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# Ignore build directories.
2+
build/
23
Build/
34
Build.*/
45
_build/
@@ -8,6 +9,9 @@ _externals/
89
# Ignore script generated files
910
Scripts/cmake/externalsConfig.cmake
1011
__pycache__
12+
.DS_Store
13+
.venv
14+
plugInfo.json
1115

1216
# Ignore IDE cache folders
1317
.vs/

Applications/Plasma/AppDelegate.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
2+
#import <Cocoa/Cocoa.h>
3+
4+
@interface AppDelegate : NSObject <NSApplicationDelegate>
5+
6+
@property (assign) IBOutlet NSWindow *window;
7+
8+
@end

Applications/Plasma/AppDelegate.m

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
#import "AppDelegate.h"
3+
4+
@interface AppDelegate ()
5+
6+
@end
7+
8+
@implementation AppDelegate
9+
10+
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
11+
// Insert code here to initialize your application
12+
}
13+
14+
- (void)applicationWillTerminate:(NSNotification *)aNotification {
15+
// Insert code here to tear down your application
16+
}
17+
18+
- (BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication *)sender {
19+
return YES;
20+
}
21+
22+
@end

Applications/Plasma/CMakeLists.txt

Lines changed: 103 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
project(Plasma)
22

3-
if(WIN32)
3+
if((WIN32 AND NOT ENABLE_HGI_BACKEND) OR APPLE)
44
option(ENABLE_INTERACTIVE_PLASMA "Build Plasma as an interactive viewer." ON)
55
else()
66
set(ENABLE_INTERACTIVE_PLASMA OFF)
@@ -12,23 +12,108 @@ find_package(cxxopts REQUIRED)
1212
find_package(stb REQUIRED)
1313
find_package(TinyGLTF REQUIRED)
1414
find_package(tinyobjloader REQUIRED)
15+
set(optionalLibraries "")
1516

16-
# Add test executable with all source files.
17-
add_executable(${PROJECT_NAME}
18-
"Camera.cpp"
19-
"Camera.h"
20-
"Plasma.cpp"
21-
"Plasma.h"
22-
"glTFLoader.cpp"
23-
"Libraries.cpp"
24-
"Loaders.h"
25-
"OBJLoader.cpp"
26-
"pch.h"
27-
"PerformanceMonitor.h"
28-
"resource.h"
29-
"SceneContents.cpp"
30-
"SceneContents.h"
31-
)
17+
if (APPLE)
18+
# Find and link the Metal framework
19+
find_library(METAL_FRAMEWORK Metal)
20+
find_library(METAL_KIT MetalKit)
21+
find_library(APP_KIT AppKit)
22+
find_library(GAME_CONTROLLER GameController)
23+
find_library(UNIFORM_TYPE_IDENTIFIERS UniformTypeIdentifiers)
24+
25+
list(APPEND optionalLibraries ${METAL_FRAMEWORK} ${METAL_KIT} ${APP_KIT} ${GAME_CONTROLLER} ${UNIFORM_TYPE_IDENTIFIERS})
26+
27+
set(APP_BUNDLE_IDENTIFIER "com.autodesk.${PROJECT_NAME}")
28+
set(DEPLOYMENT_TARGET 14.0)
29+
30+
set(PRODUCT_NAME ${PROJECT_NAME})
31+
set(EXECUTABLE_NAME ${PROJECT_NAME})
32+
set(MACOSX_BUNDLE_EXECUTABLE_NAME ${PROJECT_NAME})
33+
set(MACOSX_BUNDLE_INFO_STRING ${APP_BUNDLE_IDENTIFIER})
34+
set(MACOSX_BUNDLE_GUI_IDENTIFIER ${APP_BUNDLE_IDENTIFIER})
35+
set(MACOSX_BUNDLE_BUNDLE_NAME ${APP_BUNDLE_IDENTIFIER})
36+
set(MACOSX_BUNDLE_ICON_FILE "")
37+
set(MACOSX_BUNDLE_LONG_VERSION_STRING "1.0")
38+
set(MACOSX_BUNDLE_SHORT_VERSION_STRING "1.0")
39+
set(MACOSX_BUNDLE_BUNDLE_VERSION "1.0")
40+
set(MACOSX_BUNDLE_COPYRIGHT "Copyright")
41+
set(MACOSX_DEPLOYMENT_TARGET ${DEPLOYMENT_TARGET})
42+
43+
set(CMAKE_XCODE_GENERATE_SCHEME YES)
44+
set(CMAKE_XCODE_SCHEME_ENVIRONMENT
45+
HGIMETAL_DEBUG=1
46+
CACHE STRING "" FORCE)
47+
48+
# Add test executable with all source files.
49+
add_executable(${PROJECT_NAME} MACOSX_BUNDLE
50+
"Camera.cpp"
51+
"Camera.h"
52+
"Plasma.cpp"
53+
"Plasma.h"
54+
"glTFLoader.cpp"
55+
"Libraries.cpp"
56+
"Loaders.h"
57+
"OBJLoader.cpp"
58+
"pch.h"
59+
"PerformanceMonitor.h"
60+
"resource.h"
61+
"SceneContents.cpp"
62+
"SceneContents.h"
63+
"AppDelegate.h"
64+
"AppDelegate.m"
65+
"Renderer.h"
66+
"Renderer.mm"
67+
"PlasmaViewController.h"
68+
"PlasmaViewController.mm"
69+
"PlasmaView.h"
70+
"PlasmaView.mm"
71+
"Shaders.metal"
72+
"ShaderTypes.h"
73+
)
74+
75+
set_source_files_properties(Plasma.cpp PROPERTIES LANGUAGE OBJCXX)
76+
77+
# Add the .storyboard file and set its properties
78+
set(UI_STORYBOARD Main.storyboard)
79+
set_source_files_properties(${UI_STORYBOARD} PROPERTIES MACOSX_PACKAGE_LOCATION "Resources")
80+
#set(ENTITLEMENTS_FILE Plasma_Interactive.entitlements)
81+
#set_source_files_properties(${ENTITLEMENTS_FILE} PROPERTIES MACOSX_PACKAGE_LOCATION "Resources")
82+
83+
set_source_files_properties(Shaders.metal PROPERTIES LANGUAGE METAL)
84+
85+
target_include_directories(${PROJECT_NAME}
86+
PRIVATE
87+
"${TinyGLTF_INCLUDE_DIR}"
88+
)
89+
90+
# Add the .storyboard file to the target
91+
target_sources(${PROJECT_NAME} PRIVATE ${UI_STORYBOARD})
92+
93+
#set_target_properties(${PROJECT_NAME} PROPERTIES XCODE_ATTRIBUTE_CODE_SIGN_ENTITLEMENTS "${CMAKE_CURRENT_SOURCE_DIR}/${ENTITLEMENTS_FILE}")
94+
95+
set_target_properties(${PROJECT_NAME} PROPERTIES
96+
BUNDLE True
97+
MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/info.plist.in
98+
)
99+
else()
100+
# Add test executable with all source files.
101+
add_executable(${PROJECT_NAME}
102+
"Camera.cpp"
103+
"Camera.h"
104+
"Plasma.cpp"
105+
"Plasma.h"
106+
"glTFLoader.cpp"
107+
"Libraries.cpp"
108+
"Loaders.h"
109+
"OBJLoader.cpp"
110+
"pch.h"
111+
"PerformanceMonitor.h"
112+
"resource.h"
113+
"SceneContents.cpp"
114+
"SceneContents.h"
115+
)
116+
endif()
32117

33118
# Set custom output properties.
34119
set_target_properties(${PROJECT_NAME} PROPERTIES
@@ -57,6 +142,7 @@ PRIVATE
57142
Aurora
58143
${WINSDK_LIB}
59144
${CMAKE_DL_LIBS}
145+
${optionalLibraries}
60146
)
61147

62148
if(WIN32 AND ENABLE_INTERACTIVE_PLASMA)

Applications/Plasma/Camera.cpp

Lines changed: 71 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2023 Autodesk, Inc.
1+
// Copyright 2025 Autodesk, Inc.
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.
@@ -15,6 +15,9 @@
1515

1616
#include "Camera.h"
1717

18+
#include <glm/gtx/matrix_decompose.hpp>
19+
#include <glm/gtx/quaternion.hpp>
20+
1821
// The canonical direction vectors.
1922
static constexpr vec3 kForward = vec3(0.0f, 0.0f, -1.0f);
2023
static constexpr vec3 kRight = vec3(1.0f, 0.0f, 0.0f);
@@ -106,12 +109,21 @@ void Camera::setProjection(float fov, float nearClip, float farClip)
106109
{
107110
assert(fov > 0.0f && nearClip > 0.0f && farClip > 0.0f);
108111

109-
// Set the projection properties.
110-
_fov = fov;
111-
_near = nearClip;
112-
_far = farClip;
112+
_fromFov = _fov;
113+
_destFov = fov;
114+
115+
_fromNear = _near;
116+
_destNear = nearClip;
117+
118+
_fromFar = _far;
119+
_destFar = farClip;
120+
// APPLE TODO: _moveT = 0.0f;
121+
}
113122

114-
_isProjDirty = true;
123+
void Camera::setAspect(float aspect) {
124+
_fromAspect = _aspectRatio;
125+
_destAspect = aspect;
126+
// APPLE TODO: _moveT = 0.0f;
115127
}
116128

117129
void Camera::setDimensions(const ivec2& dimensions)
@@ -120,6 +132,7 @@ void Camera::setDimensions(const ivec2& dimensions)
120132

121133
// Set the dimensions.
122134
_dimensions = dimensions;
135+
_aspectRatio = static_cast<float>(_dimensions.x) / _dimensions.y;
123136

124137
_isProjDirty = true;
125138
}
@@ -273,4 +286,55 @@ void Camera::dolly(const vec2& delta)
273286
// NOTE: The projection matrix is dirty because the target distance may have changed here.
274287
_isViewDirty = true;
275288
_isProjDirty = true;
276-
}
289+
}
290+
291+
void Camera::moveTo(const mat4& destViewMatrix) {
292+
_fromView = _viewMatrix;
293+
_destView = destViewMatrix;
294+
_moveT = 0.0f;
295+
}
296+
297+
void Camera::update(float delta) {
298+
if (isMoving()) {
299+
_moveT += delta;
300+
float easedT = easeInOutCubic(_moveT);
301+
_viewMatrix = tweenCameraViewMatrix(_fromView, _destView, easedT);
302+
_fov = mix(_fromFov, _destFov, easedT);
303+
_near = mix(_fromNear, _destNear, easedT);
304+
_far = mix(_fromFar, _destFar, easedT);
305+
_aspectRatio = mix(_fromAspect, _destAspect, easedT);
306+
_isProjDirty = true;
307+
}
308+
}
309+
310+
mat4 Camera::tweenCameraViewMatrix(const mat4& from, const mat4& to, float t) {
311+
// Extract translation directly from matrix
312+
vec3 translationA = vec3(from[3]);
313+
vec3 translationB = vec3(to[3]);
314+
315+
// Extract rotation assuming no scale/skew (orthonormal matrix)
316+
quat rotationA = quat_cast(mat3(from));
317+
quat rotationB = quat_cast(mat3(to));
318+
319+
// Interpolate
320+
vec3 interpTranslation = mix(translationA, translationB, t);
321+
quat interpRotation = slerp(rotationA, rotationB, t);
322+
323+
// Recompose
324+
mat4 rotationMat = toMat4(interpRotation);
325+
rotationMat[3] = vec4(interpTranslation, 1.0f);
326+
327+
return rotationMat;
328+
}
329+
330+
float Camera::easeInOutCubic(float t) {
331+
float f;
332+
if(t < 0.5f) {
333+
f = 4.0f * t * t * t;
334+
}
335+
else {
336+
t = 1.0f - t;
337+
f = 1.0f - 4.0f * t * t * t;
338+
}
339+
return f;
340+
}

Applications/Plasma/Camera.h

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2023 Autodesk, Inc.
1+
// Copyright 2025 Autodesk, Inc.
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.
@@ -36,28 +36,37 @@ class Camera
3636
vec3 forwardDir() const { return normalize(_target - _eye); }
3737
vec3 rightDir() const { return cross(forwardDir(), _up); }
3838
float targetDistance() const { return length(_target - _eye); }
39-
float aspectRatio() const { return static_cast<float>(_dimensions.x) / _dimensions.y; }
39+
float aspectRatio() const { return _aspectRatio; }
4040
const mat4& viewMatrix();
4141
const mat4& projMatrix();
4242
const ivec2& dimensions() const { return _dimensions; }
4343
bool isDirty() { return _isViewDirty || _isProjDirty; }
4444
void setIsOrtho(bool value);
4545
void setView(const vec3& eye, const vec3& target);
4646
void setProjection(float fov, float nearClip, float farClip);
47+
void setAspect(float aspect);
4748
void setDimensions(const ivec2& dimensions);
4849
void fit(const Foundation::BoundingBox& bounds);
4950
void fit(const Foundation::BoundingBox& bounds, const vec3& direction);
5051
void mouseMove(int xPos, int yPos, const Inputs& inputs);
51-
52+
float fov() const { return _fov; }
53+
float getNear() const { return _near; }
54+
float getFar() const { return _far; }
55+
bool isOrtho() const { return _isOrtho; }
56+
57+
void moveTo(const mat4& destViewMatrix);
58+
void update(float delta);
59+
bool isMoving() const { return (_moveT < 1.0f); }
60+
5261
private:
5362
/*** Private Functions ***/
54-
63+
5564
void orbit(const vec2& delta);
5665
void pan(const vec2& delta);
5766
void dolly(const vec2& delta);
58-
67+
5968
/*** Private Variables ***/
60-
69+
6170
bool _isUpdating = false;
6271
vec2 _lastMouse;
6372
bool _isViewDirty = true;
@@ -72,6 +81,17 @@ class Camera
7281
vec3 _target = vec3(0.0f, 0.0f, 0.0f);
7382
vec3 _up = vec3(0.0f, 1.0f, 0.0f);
7483
ivec2 _dimensions = ivec2(100, 100);
84+
float _aspectRatio = 1.0f;
7585
mat4 _viewMatrix;
7686
mat4 _projMatrix;
77-
};
87+
88+
float _moveT = 1.0f;
89+
mat4 _destView, _fromView;
90+
float _destFov, _destNear, _destFar, _destAspect;
91+
float _fromFov, _fromNear, _fromFar, _fromAspect;
92+
93+
94+
mat4 tweenCameraViewMatrix(const mat4& from, const mat4& to, float t);
95+
float easeInOutCubic(float t);
96+
97+
};

Applications/Plasma/Libraries.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2023 Autodesk, Inc.
1+
// Copyright 2025 Autodesk, Inc.
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.
@@ -13,11 +13,12 @@
1313
// limitations under the License.
1414
#include "pch.h"
1515

16-
#if defined(INTERACTIVE_PLASMA)
16+
#if defined(INTERACTIVE_PLASMA) && defined(WIN32)
1717
// Window global variable from pch.h.
1818
HWND gWindow = nullptr;
1919
#endif
2020

21+
#if !defined(__APPLE__)
2122
// Prepare the implementations of these header-only libraries.
2223
// NOTE: This must be done in a *single* source file; other source files can just include the
2324
// header(s).
@@ -28,6 +29,10 @@ HWND gWindow = nullptr;
2829
#include <tiny_gltf.h>
2930
#pragma warning(push)
3031
#pragma warning(disable : 4996)
32+
#pragma clang diagnostic push
33+
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
3134
#define STB_IMAGE_WRITE_IMPLEMENTATION
3235
#include <stb_image_write.h>
33-
#pragma warning(pop)
36+
#pragma clang diagnostic pop
37+
#pragma warning(pop)
38+
#endif

0 commit comments

Comments
 (0)