From 43d47745dd519aafed8339f3776a37df72ed5958 Mon Sep 17 00:00:00 2001 From: Mathias Agopian Date: Fri, 14 May 2021 11:38:13 -0700 Subject: [PATCH] API CHANGE: remove deprecated populateTangentQuaternions --- RELEASE_NOTES.md | 1 + .../src/main/cpp/VertexBuffer.cpp | 40 ---------- .../google/android/filament/VertexBuffer.java | 78 ------------------- filament/CMakeLists.txt | 1 - filament/include/filament/VertexBuffer.h | 45 ----------- filament/src/VertexBuffer.cpp | 24 ------ 6 files changed, 1 insertion(+), 188 deletions(-) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index c41eefdff4..cf4c928a77 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -6,6 +6,7 @@ A new header is inserted each time a *tag* is created. ## v1.10.0 (currently main branch) - engine: User materials can now use 9 samplers instead of 8 [⚠️ **Material breakage**]. +- engine: Remove `populateTangentQuaternions` [⚠️ **API change**]. ## v1.9.25 diff --git a/android/filament-android/src/main/cpp/VertexBuffer.cpp b/android/filament-android/src/main/cpp/VertexBuffer.cpp index ed9460e17a..8bc1e99e55 100644 --- a/android/filament-android/src/main/cpp/VertexBuffer.cpp +++ b/android/filament-android/src/main/cpp/VertexBuffer.cpp @@ -130,43 +130,3 @@ Java_com_google_android_filament_VertexBuffer_nSetBufferObjectAt(JNIEnv *env, jc BufferObject *bufferObject = (BufferObject *) nativeBufferObject; vertexBuffer->setBufferObjectAt(*engine, (uint8_t) bufferIndex, bufferObject); } - -extern "C" [[deprecated]] JNIEXPORT void JNICALL -Java_com_google_android_filament_VertexBuffer_nPopulateTangentQuaternions(JNIEnv *env, - jclass type, jint quatType, jint quatCount, jobject outBuffer, jint outRemaining, - jint outStride, jobject normals, jint normalsRemaining, jint normalsStride, - jobject tangents, jint tangentsRemaining, jint tangentsStride) { - - AutoBuffer outNioBuffer(env, outBuffer, outRemaining, true); - void* outData = outNioBuffer.getData(); - - AutoBuffer normalsNioBuffer(env, normals, normalsRemaining); - auto normalsData = (const float3*) normalsNioBuffer.getData(); - - if (tangents) { - AutoBuffer tangentsNioBuffer(env, tangents, tangentsRemaining); - auto tangentsData = (const float4*) tangentsNioBuffer.getData(); - VertexBuffer::populateTangentQuaternions({ - .quatType = (VertexBuffer::QuatType) quatType, - .quatCount = (size_t) quatCount, - .outBuffer = outData, - .outStride = (size_t) outStride, - .normals = normalsData, - .normalsStride = (size_t) normalsStride, - .tangents = tangentsData, - .tangentsStride = (size_t) tangentsStride - }); - return; - } - - VertexBuffer::populateTangentQuaternions({ - .quatType = (VertexBuffer::QuatType) quatType, - .quatCount = (size_t) quatCount, - .outBuffer = outData, - .outStride = (size_t) outStride, - .normals = normalsData, - .normalsStride = (size_t) normalsStride, - .tangents = nullptr, - .tangentsStride = 0 - }); -} diff --git a/android/filament-android/src/main/java/com/google/android/filament/VertexBuffer.java b/android/filament-android/src/main/java/com/google/android/filament/VertexBuffer.java index 0ff6f52c2e..d3494e81ef 100644 --- a/android/filament-android/src/main/java/com/google/android/filament/VertexBuffer.java +++ b/android/filament-android/src/main/java/com/google/android/filament/VertexBuffer.java @@ -104,48 +104,6 @@ public class VertexBuffer { HALF3, HALF4, } - /** - * Specifies the quaternion type for the {@link #populateTangentQuaternions} utility. - */ - public enum QuatType { - /** 2 bytes per component as half-floats (8 bytes per quat) */ - HALF4, - - /** 2 bytes per component as normalized integers (8 bytes per quat) */ - SHORT4, - - /** 4 bytes per component as floats (16 bytes per quat) */ - FLOAT4, - } - - /** - * Specifies the parameters for the {@link #populateTangentQuaternions} utility. - */ - public static class QuatTangentContext { - /** desired quaternion type (required) */ - public QuatType quatType; - - /** number of quaternions (required) */ - public int quatCount; - - /** pre-allocated output buffer (required) */ - public Buffer outBuffer; - - /** desired stride in bytes (optional) */ - public int outStride; - - /** source normals (required) */ - public Buffer normals; - - /** normals stride in bytes (optional) */ - public int normalsStride; - - /** source tangents (optional) */ - public Buffer tangents; - - /** tangents stride in bytes (optional) */ - public int tangentsStride; - } public static class Builder { @SuppressWarnings({"FieldCanBeLocal", "UnusedDeclaration"}) // Keep to finalize native resources @@ -429,38 +387,6 @@ public class VertexBuffer { bufferObject.getNativeObject()); } - /** - * Convenience function that consumes normal vectors (and, optionally, tangent vectors) and - * produces quaternions that can be passed into a TANGENTS buffer. - * - *

- * The given output buffer must be preallocated with at least quatCount * outStride bytes. - *

- * - *

- * Normals are required but tangents are optional, in which case this function tries to generate - * reasonable tangents. The given normals should be unit length. - *

- * - *

- * If supplied, the tangent vectors should be unit length and should be orthogonal to the - * normals. The w component of the tangent is a sign (-1 or +1) indicating handedness of the - * basis. - *

- * - * @deprecated Instead please use SurfaceOrientation since it has additional capabilities and a - * builder-style API. - * - * @param context an initialized QuatTangentContext object - */ - public static void populateTangentQuaternions(@NonNull QuatTangentContext context) { - nPopulateTangentQuaternions(context.quatType.ordinal(), context.quatCount, - context.outBuffer, context.outBuffer.remaining(), context.outStride, - context.normals, context.normals.remaining(), context.normalsStride, - context.tangents, context.tangents != null ? context.tangents.remaining() : 0, - context.tangentsStride); - } - public long getNativeObject() { if (mNativeObject == 0) { throw new IllegalStateException("Calling method on destroyed VertexBuffer"); @@ -490,8 +416,4 @@ public class VertexBuffer { private static native void nSetBufferObjectAt(long nativeVertexBuffer, long nativeEngine, int bufferIndex, long nativeBufferObject); - - private static native void nPopulateTangentQuaternions(int quatType, int quatCount, - Buffer outBuffer, int outRemaining, int outStride, Buffer normals, int normalsRemaining, - int normalsStride, Buffer tangents, int tangentsRemaining, int tangentsStride); } diff --git a/filament/CMakeLists.txt b/filament/CMakeLists.txt index 09c77ebb74..f41f71a915 100644 --- a/filament/CMakeLists.txt +++ b/filament/CMakeLists.txt @@ -363,7 +363,6 @@ target_include_directories(${TARGET} PUBLIC ${PUBLIC_HDR_DIR}) target_link_libraries(${TARGET} PUBLIC backend) target_link_libraries(${TARGET} PUBLIC math) target_link_libraries(${TARGET} PUBLIC utils) -target_link_libraries(${TARGET} PUBLIC geometry) # TODO: remove this dependency after deprecating VertexBuffer::populateTangentQuaternions target_link_libraries(${TARGET} PUBLIC filaflat) target_link_libraries(${TARGET} PUBLIC filabridge) target_link_libraries(${TARGET} PUBLIC ibl-lite) diff --git a/filament/include/filament/VertexBuffer.h b/filament/include/filament/VertexBuffer.h index 51c2c247bc..9557a541bc 100644 --- a/filament/include/filament/VertexBuffer.h +++ b/filament/include/filament/VertexBuffer.h @@ -194,51 +194,6 @@ public: * @param bufferObject The handle to the GPU data that will be used in this buffer slot. */ void setBufferObjectAt(Engine& engine, uint8_t bufferIndex, BufferObject const* bufferObject); - - /** - * Specifies the quaternion type for the "populateTangentQuaternions" utility. - */ - enum QuatType { - HALF4, //!< 2 bytes per component as half-floats (8 bytes per quat) - SHORT4, //!< 2 bytes per component as normalized integers (8 bytes per quat) - FLOAT4, //!< 4 bytes per component as floats (16 bytes per quat) - }; - - /** - * Specifies the parameters for the "populateTangentQuaternions" utility. - */ - struct QuatTangentContext { - QuatType quatType; //!< desired quaternion type (required) - size_t quatCount; //!< number of quaternions (required) - void* outBuffer; //!< pre-allocated output buffer (required) - size_t outStride; //!< desired stride in bytes (optional) - const math::float3* normals; //!< source normals (required) - size_t normalsStride; //!< normals stride in bytes (optional) - const math::float4* tangents; //!< source tangents (optional) - size_t tangentsStride; //!< tangents stride in bytes (optional) - }; - - /** - * Convenience function that consumes normal vectors (and, optionally, tangent vectors) and - * produces quaternions that can be passed into a TANGENTS buffer. - * - * The given output buffer must be preallocated with at least quatCount * outStride bytes. - * - * Normals are required but tangents are optional, in which case this function tries to generate - * reasonable tangents. The given normals should be unit length. - * - * If supplied, the tangent vectors should be unit length and should be orthogonal to the - * normals. The w component of the tangent is a sign (-1 or +1) indicating handedness of the - * basis. - * - * @param ctx An initialized QuatTangentContext structure. - * - * @deprecated Instead please use filament::geometry::SurfaceOrientation from libgeometry, it - * has additional capabilities and a daisy-chain API. Be sure to explicitly link libgeometry - * since its dependency might be removed in future versions of libfilament. - */ - UTILS_DEPRECATED - static void populateTangentQuaternions(const QuatTangentContext& ctx); }; } // namespace filament diff --git a/filament/src/VertexBuffer.cpp b/filament/src/VertexBuffer.cpp index bd3d78a6e4..d97243e4ae 100644 --- a/filament/src/VertexBuffer.cpp +++ b/filament/src/VertexBuffer.cpp @@ -21,8 +21,6 @@ #include "FilamentAPI-impl.h" -#include - #include #include @@ -266,26 +264,4 @@ void VertexBuffer::setBufferObjectAt(Engine& engine, uint8_t bufferIndex, upcast(this)->setBufferObjectAt(upcast(engine), bufferIndex, upcast(bufferObject)); } -void VertexBuffer::populateTangentQuaternions(const QuatTangentContext& ctx) { - auto* quats = geometry::SurfaceOrientation::Builder() - .vertexCount(ctx.quatCount) - .normals(ctx.normals, ctx.normalsStride) - .tangents(ctx.tangents, ctx.tangentsStride) - .build(); - - switch (ctx.quatType) { - case HALF4: - quats->getQuats((quath*) ctx.outBuffer, ctx.quatCount, ctx.outStride); - break; - case SHORT4: - quats->getQuats((short4*) ctx.outBuffer, ctx.quatCount, ctx.outStride); - break; - case FLOAT4: - quats->getQuats((quatf*) ctx.outBuffer, ctx.quatCount, ctx.outStride); - break; - } - - delete quats; -} - } // namespace filament