Merge model and skinned model windows code into shared base class
This commit is contained in:
@@ -8,16 +8,15 @@
|
||||
/// <summary>
|
||||
/// Represents single Level Of Detail for the model. Contains a collection of the meshes.
|
||||
/// </summary>
|
||||
API_CLASS(NoSpawn) class FLAXENGINE_API ModelLOD : public ScriptingObject
|
||||
API_CLASS(NoSpawn) class FLAXENGINE_API ModelLOD : public ModelLODBase
|
||||
{
|
||||
DECLARE_SCRIPTING_TYPE_WITH_CONSTRUCTOR_IMPL(ModelLOD, ScriptingObject);
|
||||
DECLARE_SCRIPTING_TYPE_WITH_CONSTRUCTOR_IMPL(ModelLOD, ModelLODBase);
|
||||
friend Model;
|
||||
friend Mesh;
|
||||
|
||||
private:
|
||||
Model* _model = nullptr;
|
||||
int32 _lodIndex = 0;
|
||||
uint32 _verticesCount = 0;
|
||||
Model* _model = nullptr;
|
||||
|
||||
void Link(Model* model, int32 lodIndex)
|
||||
{
|
||||
@@ -27,30 +26,11 @@ private:
|
||||
}
|
||||
|
||||
public:
|
||||
/// <summary>
|
||||
/// The screen size to switch LODs. Bottom limit of the model screen size to render this LOD.
|
||||
/// </summary>
|
||||
API_FIELD() float ScreenSize = 1.0f;
|
||||
|
||||
/// <summary>
|
||||
/// The meshes array.
|
||||
/// </summary>
|
||||
API_FIELD(ReadOnly) Array<Mesh> Meshes;
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether any mesh has been initialized.
|
||||
/// </summary>
|
||||
/// <returns>True if any mesh has been initialized, otherwise false.</returns>
|
||||
bool HasAnyMeshInitialized() const;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the model LOD index.
|
||||
/// </summary>
|
||||
API_PROPERTY() FORCE_INLINE int32 GetLODIndex() const
|
||||
{
|
||||
return _lodIndex;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the vertex count for this model LOD level.
|
||||
/// </summary>
|
||||
@@ -82,26 +62,6 @@ public:
|
||||
/// <returns>True whether the two objects intersected</returns>
|
||||
bool Intersects(const Ray& ray, const Transform& transform, Real& distance, Vector3& normal, Mesh** mesh);
|
||||
|
||||
/// <summary>
|
||||
/// Get model bounding box in transformed world matrix.
|
||||
/// </summary>
|
||||
/// <param name="world">World matrix</param>
|
||||
/// <returns>Bounding box</returns>
|
||||
BoundingBox GetBox(const Matrix& world) const;
|
||||
|
||||
/// <summary>
|
||||
/// Get model bounding box in transformed world.
|
||||
/// </summary>
|
||||
/// <param name="transform">The instance transformation.</param>
|
||||
/// <param name="deformation">The meshes deformation container (optional).</param>
|
||||
/// <returns>Bounding box</returns>
|
||||
BoundingBox GetBox(const Transform& transform, const MeshDeformation* deformation = nullptr) const;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the bounding box combined for all meshes in this model LOD.
|
||||
/// </summary>
|
||||
API_PROPERTY() BoundingBox GetBox() const;
|
||||
|
||||
/// <summary>
|
||||
/// Draws the meshes. Binds vertex and index buffers and invokes the draw calls.
|
||||
/// </summary>
|
||||
@@ -152,6 +112,14 @@ public:
|
||||
for (int32 i = 0; i < Meshes.Count(); i++)
|
||||
Meshes.Get()[i].Draw(renderContextBatch, info, lodDitherFactor);
|
||||
}
|
||||
|
||||
public:
|
||||
// [ModelLODBase]
|
||||
int32 GetMeshesCount() const override;
|
||||
const MeshBase* GetMesh(int32 index) const override;
|
||||
MeshBase* GetMesh(int32 index) override;
|
||||
void GetMeshes(Array<MeshBase*>& meshes) override;
|
||||
void GetMeshes(Array<const MeshBase*>& meshes) const override;
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
@@ -312,6 +280,8 @@ public:
|
||||
// [ModelBase]
|
||||
void SetupMaterialSlots(int32 slotsCount) override;
|
||||
int32 GetLODsCount() const override;
|
||||
const ModelLODBase* GetLOD(int32 lodIndex) const override;
|
||||
ModelLODBase* GetLOD(int32 lodIndex) override;
|
||||
const MeshBase* GetMesh(int32 meshIndex, int32 lodIndex = 0) const override;
|
||||
MeshBase* GetMesh(int32 meshIndex, int32 lodIndex = 0) override;
|
||||
void GetMeshes(Array<const MeshBase*>& meshes, int32 lodIndex = 0) const override;
|
||||
|
||||
Reference in New Issue
Block a user