From 88e4ddeec7d0e643add0473d97e156beb1148d2f Mon Sep 17 00:00:00 2001 From: Mathias Agopian Date: Fri, 5 Sep 2025 11:52:13 -0700 Subject: [PATCH] View::setCamera() should accept nullptr FIXES=[441757817] --- .../src/main/java/com/google/android/filament/View.java | 2 +- filament/include/filament/View.h | 9 +++++++-- filament/src/details/View.h | 2 +- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/android/filament-android/src/main/java/com/google/android/filament/View.java b/android/filament-android/src/main/java/com/google/android/filament/View.java index 166845d8cc..fc53e148d7 100644 --- a/android/filament-android/src/main/java/com/google/android/filament/View.java +++ b/android/filament-android/src/main/java/com/google/android/filament/View.java @@ -231,7 +231,7 @@ public class View { * *

* The View does not take ownership of the Scene pointer. Before destroying a Camera, be sure - * to remove it from all assoicated Views. + * to remove it from all associated Views. If the camera isn't set, Renderer::render() will result in a no-op. *

* * @see #getCamera diff --git a/filament/include/filament/View.h b/filament/include/filament/View.h index 0ea2e8c017..8af05b8648 100644 --- a/filament/include/filament/View.h +++ b/filament/include/filament/View.h @@ -185,12 +185,13 @@ public: * View.\n * The View doesn't take ownership of the Camera pointer (which * acts as a reference). + * If the camera isn't set, Renderer::render() will result in a no-op. * * @note * There is no reference-counting. * Make sure to dissociate a Camera from all Views before destroying it. */ - void setCamera(Camera* UTILS_NONNULL camera) noexcept; + void setCamera(Camera* UTILS_NULLABLE camera) noexcept; /** * Returns whether a Camera is set. @@ -201,13 +202,17 @@ public: /** * Returns the Camera currently associated with this View. - * @return A reference to the Camera associated to this View. + * Undefined behavior if hasCamera() is false. + * @return A reference to the Camera associated to this View if hasCamera() is true. + * @see hasCamera() */ Camera& getCamera() noexcept; /** * Returns the Camera currently associated with this View. + * Undefined behavior if hasCamera() is false. * @return A reference to the Camera associated to this View. + * @see hasCamera() */ Camera const& getCamera() const noexcept { return const_cast(this)->getCamera(); diff --git a/filament/src/details/View.h b/filament/src/details/View.h index dd0cbeebd2..f20fa8aea6 100644 --- a/filament/src/details/View.h +++ b/filament/src/details/View.h @@ -550,7 +550,7 @@ private: FScene* mScene = nullptr; // The camera set by the user, used for culling and viewing - FCamera* /* UTILS_NONNULL */ mCullingCamera = nullptr; // FIXME: should always be non-null + FCamera* mCullingCamera = nullptr; // The optional (debug) camera, used only for viewing FCamera* mViewingCamera = nullptr;