Compute min/max value if min/max is not defined.
[platform/core/uifw/dali-toolkit.git] / dali-scene-loader / public-api / mesh-definition.h
index cd0ddc9..b4b2c7d 100644 (file)
@@ -1,7 +1,7 @@
 #ifndef DALI_SCENE_LOADER_MESH_DEFINITION_H
 #define DALI_SCENE_LOADER_MESH_DEFINITION_H
 /*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2022 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -78,6 +78,8 @@ struct DALI_SCENE_LOADER_API MeshDefinition
     std::vector<float> mMin;
     std::vector<float> mMax;
 
+    static void ComputeMinMax(std::vector<float>& min, std::vector<float>& max, uint32_t numComponents, uint32_t count, const float* values);
+
     static void ApplyMinMax(const std::vector<float>& min, const std::vector<float>& max, uint32_t count, float* values);
 
     Blob() = default;
@@ -107,7 +109,20 @@ struct DALI_SCENE_LOADER_API MeshDefinition
     }
 
     /**
-     * @brief Applies the min / max values, if they're defined.
+     * @brief Computes the min / max of the input value data.
+     * The min and max are stored in mMin and mMax.
+     *
+     * @param[in] numComponents number of components of data type. e.g., 3 for Vector3.
+     * @param[in] count The number of data.
+     * @param[in] values Data for the mesh.
+     */
+    void ComputeMinMax(uint32_t numComponents, uint32_t count, float* values);
+
+    /**
+     * @brief Applies the min / max values, if they're defined in the model
+     *
+     * @param[in] count The number of data.
+     * @param[in] values Data for the mesh that min / max values will be applied.
      */
     void ApplyMinMax(uint32_t count, float* values) const;
   };
@@ -177,7 +192,7 @@ struct DALI_SCENE_LOADER_API MeshDefinition
     std::vector<uint16_t> mIndices;
     std::vector<Attrib>   mAttribs;
 
-    unsigned int        mBlendShapeBufferOffset;
+    unsigned int        mBlendShapeBufferOffset{0};
     Dali::Vector<float> mBlendShapeUnnormalizeFactor;
     PixelData           mBlendShapeData;
   };
@@ -224,7 +239,7 @@ struct DALI_SCENE_LOADER_API MeshDefinition
    *  attribute buffers, as well as blend shape data. This is then returned.
    * @note This can be done on any thread.
    */
-  RawData LoadRaw(const std::string& modelsPath) const;
+  RawData LoadRaw(const std::string& modelsPath);
 
   /**
    * @brief Creates a MeshGeometry based firstly on the value of the uri member:
@@ -243,9 +258,11 @@ public: // DATA
   Accessor       mPositions;
   Accessor       mNormals; // data can be generated based on positions
   Accessor       mTexCoords;
+  Accessor       mColors;
   Accessor       mTangents; // data can be generated based on normals and texCoords (the latter isn't mandatory; the results will be better if available)
   Accessor       mJoints0;
   Accessor       mWeights0;
+  Property::Type mTangentType{Property::VECTOR3};
 
   Blob                    mBlendShapeHeader;
   std::vector<BlendShape> mBlendShapes;