Refactor objects splitting in models importing to be handled by ModelTool not the importer code itself
This commit is contained in:
@@ -625,6 +625,11 @@ bool MaterialSlotEntry::UsesProperties() const
|
||||
Normals.TextureIndex != -1;
|
||||
}
|
||||
|
||||
ModelLodData::~ModelLodData()
|
||||
{
|
||||
Meshes.ClearDelete();
|
||||
}
|
||||
|
||||
BoundingBox ModelLodData::GetBox() const
|
||||
{
|
||||
if (Meshes.IsEmpty())
|
||||
@@ -644,11 +649,9 @@ void ModelData::CalculateLODsScreenSizes()
|
||||
{
|
||||
const float autoComputeLodPowerBase = 0.5f;
|
||||
const int32 lodCount = LODs.Count();
|
||||
|
||||
for (int32 lodIndex = 0; lodIndex < lodCount; lodIndex++)
|
||||
{
|
||||
auto& lod = LODs[lodIndex];
|
||||
|
||||
if (lodIndex == 0)
|
||||
{
|
||||
lod.ScreenSize = 1.0f;
|
||||
@@ -675,6 +678,8 @@ void ModelData::TransformBuffer(const Matrix& matrix)
|
||||
}
|
||||
}
|
||||
|
||||
#if USE_EDITOR
|
||||
|
||||
bool ModelData::Pack2ModelHeader(WriteStream* stream) const
|
||||
{
|
||||
// Validate input
|
||||
@@ -880,20 +885,21 @@ bool ModelData::Pack2SkinnedModelHeader(WriteStream* stream) const
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ModelData::Pack2AnimationHeader(WriteStream* stream) const
|
||||
bool ModelData::Pack2AnimationHeader(WriteStream* stream, int32 animIndex) const
|
||||
{
|
||||
// Validate input
|
||||
if (stream == nullptr)
|
||||
if (stream == nullptr || animIndex < 0 || animIndex >= Animations.Count())
|
||||
{
|
||||
Log::ArgumentNullException();
|
||||
return true;
|
||||
}
|
||||
if (Animation.Duration <= ZeroTolerance || Animation.FramesPerSecond <= ZeroTolerance)
|
||||
auto& anim = Animations.Get()[animIndex];
|
||||
if (anim.Duration <= ZeroTolerance || anim.FramesPerSecond <= ZeroTolerance)
|
||||
{
|
||||
Log::InvalidOperationException(TEXT("Invalid animation duration."));
|
||||
return true;
|
||||
}
|
||||
if (Animation.Channels.IsEmpty())
|
||||
if (anim.Channels.IsEmpty())
|
||||
{
|
||||
Log::ArgumentOutOfRangeException(TEXT("Channels"), TEXT("Animation channels collection cannot be empty."));
|
||||
return true;
|
||||
@@ -901,22 +907,23 @@ bool ModelData::Pack2AnimationHeader(WriteStream* stream) const
|
||||
|
||||
// Info
|
||||
stream->WriteInt32(100); // Header version (for fast version upgrades without serialization format change)
|
||||
stream->WriteDouble(Animation.Duration);
|
||||
stream->WriteDouble(Animation.FramesPerSecond);
|
||||
stream->WriteBool(Animation.EnableRootMotion);
|
||||
stream->WriteString(Animation.RootNodeName, 13);
|
||||
stream->WriteDouble(anim.Duration);
|
||||
stream->WriteDouble(anim.FramesPerSecond);
|
||||
stream->WriteBool(anim.EnableRootMotion);
|
||||
stream->WriteString(anim.RootNodeName, 13);
|
||||
|
||||
// Animation channels
|
||||
stream->WriteInt32(Animation.Channels.Count());
|
||||
for (int32 i = 0; i < Animation.Channels.Count(); i++)
|
||||
stream->WriteInt32(anim.Channels.Count());
|
||||
for (int32 i = 0; i < anim.Channels.Count(); i++)
|
||||
{
|
||||
auto& anim = Animation.Channels[i];
|
||||
|
||||
stream->WriteString(anim.NodeName, 172);
|
||||
Serialization::Serialize(*stream, anim.Position);
|
||||
Serialization::Serialize(*stream, anim.Rotation);
|
||||
Serialization::Serialize(*stream, anim.Scale);
|
||||
auto& channel = anim.Channels[i];
|
||||
stream->WriteString(channel.NodeName, 172);
|
||||
Serialization::Serialize(*stream, channel.Position);
|
||||
Serialization::Serialize(*stream, channel.Rotation);
|
||||
Serialization::Serialize(*stream, channel.Scale);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -405,10 +405,7 @@ struct FLAXENGINE_API ModelLodData
|
||||
/// <summary>
|
||||
/// Finalizes an instance of the <see cref="ModelLodData"/> class.
|
||||
/// </summary>
|
||||
~ModelLodData()
|
||||
{
|
||||
Meshes.ClearDelete();
|
||||
}
|
||||
~ModelLodData();
|
||||
|
||||
/// <summary>
|
||||
/// Gets the bounding box combined for all meshes in this model LOD.
|
||||
@@ -455,15 +452,7 @@ public:
|
||||
/// <summary>
|
||||
/// The node animations.
|
||||
/// </summary>
|
||||
AnimationData Animation;
|
||||
|
||||
public:
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ModelData"/> class.
|
||||
/// </summary>
|
||||
ModelData()
|
||||
{
|
||||
}
|
||||
Array<AnimationData> Animations;
|
||||
|
||||
public:
|
||||
/// <summary>
|
||||
@@ -494,6 +483,7 @@ public:
|
||||
/// <param name="matrix">The matrix to use for the transformation.</param>
|
||||
void TransformBuffer(const Matrix& matrix);
|
||||
|
||||
#if USE_EDITOR
|
||||
public:
|
||||
/// <summary>
|
||||
/// Pack mesh data to the header stream
|
||||
@@ -513,6 +503,8 @@ public:
|
||||
/// Pack animation data to the header stream
|
||||
/// </summary>
|
||||
/// <param name="stream">Output stream</param>
|
||||
/// <param name="animIndex">Index of animation.</param>
|
||||
/// <returns>True if cannot save data, otherwise false</returns>
|
||||
bool Pack2AnimationHeader(WriteStream* stream) const;
|
||||
bool Pack2AnimationHeader(WriteStream* stream, int32 animIndex = 0) const;
|
||||
#endif
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user