From 66ad099545fec334fa64c18ea067417d7c366544 Mon Sep 17 00:00:00 2001 From: Jacky Tsang Date: Mon, 30 Oct 2023 22:37:27 +0000 Subject: [PATCH] Made materialInstance nullable --- .../src/main/java/io/github/sceneview/node/CubeNode.kt | 4 ++-- .../main/java/io/github/sceneview/node/CylinderNode.kt | 4 ++-- .../main/java/io/github/sceneview/node/GeometryNode.kt | 10 +++++----- .../main/java/io/github/sceneview/node/PlaneNode.kt | 4 ++-- .../main/java/io/github/sceneview/node/SphereNode.kt | 4 ++-- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/sceneview/src/main/java/io/github/sceneview/node/CubeNode.kt b/sceneview/src/main/java/io/github/sceneview/node/CubeNode.kt index e2f5d867..a2fbf68e 100644 --- a/sceneview/src/main/java/io/github/sceneview/node/CubeNode.kt +++ b/sceneview/src/main/java/io/github/sceneview/node/CubeNode.kt @@ -21,7 +21,7 @@ open class CubeNode( * Should return the material to bind for the zero-based index of the primitive, must be less * than the [Geometry.submeshes] size passed to constructor. */ - materialInstances: (index: Int) -> MaterialInstance, + materialInstances: (index: Int) -> MaterialInstance?, /** * The parent node. * @@ -51,7 +51,7 @@ open class CubeNode( /** * Binds a material instance to all primitives. */ - materialInstance: MaterialInstance, + materialInstance: MaterialInstance?, parent: Node? = null, renderableApply: RenderableManager.Builder.() -> Unit = {} ) : this( diff --git a/sceneview/src/main/java/io/github/sceneview/node/CylinderNode.kt b/sceneview/src/main/java/io/github/sceneview/node/CylinderNode.kt index 6466ac27..d8e9c5c8 100644 --- a/sceneview/src/main/java/io/github/sceneview/node/CylinderNode.kt +++ b/sceneview/src/main/java/io/github/sceneview/node/CylinderNode.kt @@ -22,7 +22,7 @@ open class CylinderNode( * Should return the material to bind for the zero-based index of the primitive, must be less * than the [Geometry.submeshes] size passed to constructor. */ - materialInstances: (index: Int) -> MaterialInstance, + materialInstances: (index: Int) -> MaterialInstance?, /** * The parent node. * @@ -56,7 +56,7 @@ open class CylinderNode( /** * Binds a material instance to all primitives. */ - materialInstance: MaterialInstance, + materialInstance: MaterialInstance?, parent: Node? = null, renderableApply: RenderableManager.Builder.() -> Unit = {} ) : this( diff --git a/sceneview/src/main/java/io/github/sceneview/node/GeometryNode.kt b/sceneview/src/main/java/io/github/sceneview/node/GeometryNode.kt index f84dc1b5..9bed94dd 100644 --- a/sceneview/src/main/java/io/github/sceneview/node/GeometryNode.kt +++ b/sceneview/src/main/java/io/github/sceneview/node/GeometryNode.kt @@ -45,7 +45,7 @@ open class GeometryNode( * Should return the material to bind for the zero-based index of the primitive, must be less * than the [Geometry.submeshes] size passed to constructor. */ - materialInstances: (index: Int) -> MaterialInstance, + materialInstances: (index: Int) -> MaterialInstance?, /** * The parent node. * @@ -75,7 +75,7 @@ open class GeometryNode( /** * Binds a material instance to all primitives. */ - materialInstance: MaterialInstance, + materialInstance: MaterialInstance?, parent: Node? = null, renderableApply: RenderableManager.Builder.() -> Unit = {} ) : this( @@ -105,7 +105,7 @@ open class BaseGeometryNode( * Should return the material to bind for the zero-based index of the primitive, must be less * than the [Geometry.submeshes] size passed to constructor. */ - materialInstances: (index: Int) -> MaterialInstance, + materialInstances: (index: Int) -> MaterialInstance?, /** * The parent node. * @@ -125,7 +125,7 @@ open class BaseGeometryNode( /** * Binds a material instance to all primitives. */ - materialInstance: MaterialInstance, + materialInstance: MaterialInstance?, parent: Node? = null, renderableApply: RenderableManager.Builder.() -> Unit = {} ) : this( @@ -141,7 +141,7 @@ open class BaseGeometryNode( .geometry(geometry) .apply { geometry.submeshes.forEachIndexed { index, _ -> - material(index, materialInstances(index)) + materialInstances(index)?.let { material(index, it) } } } .apply(renderableApply) diff --git a/sceneview/src/main/java/io/github/sceneview/node/PlaneNode.kt b/sceneview/src/main/java/io/github/sceneview/node/PlaneNode.kt index ed8247e7..b2b9fa2c 100644 --- a/sceneview/src/main/java/io/github/sceneview/node/PlaneNode.kt +++ b/sceneview/src/main/java/io/github/sceneview/node/PlaneNode.kt @@ -23,7 +23,7 @@ open class PlaneNode( * Should return the material to bind for the zero-based index of the primitive, must be less * than the [Geometry.submeshes] size passed to constructor. */ - materialInstances: (index: Int) -> MaterialInstance, + materialInstances: (index: Int) -> MaterialInstance?, /** * The parent node. * @@ -55,7 +55,7 @@ open class PlaneNode( /** * Binds a material instance to all primitives. */ - materialInstance: MaterialInstance, + materialInstance: MaterialInstance?, parent: Node? = null, renderableApply: RenderableManager.Builder.() -> Unit = {} ) : this( diff --git a/sceneview/src/main/java/io/github/sceneview/node/SphereNode.kt b/sceneview/src/main/java/io/github/sceneview/node/SphereNode.kt index 48dc85e5..052421ad 100644 --- a/sceneview/src/main/java/io/github/sceneview/node/SphereNode.kt +++ b/sceneview/src/main/java/io/github/sceneview/node/SphereNode.kt @@ -22,7 +22,7 @@ open class SphereNode( * Should return the material to bind for the zero-based index of the primitive, must be less * than the [Geometry.submeshes] size passed to constructor. */ - materialInstances: (index: Int) -> MaterialInstance, + materialInstances: (index: Int) -> MaterialInstance?, /** * The parent node. * @@ -56,7 +56,7 @@ open class SphereNode( /** * Binds a material instance to all primitives. */ - materialInstance: MaterialInstance, + materialInstance: MaterialInstance?, parent: Node? = null, renderableApply: RenderableManager.Builder.() -> Unit = {} ) : this(