This commit is contained in:
Wojtek Figat
2021-10-07 09:29:36 +02:00
parent 0bd5f63ae4
commit 397edf18b9
2 changed files with 14 additions and 67 deletions

View File

@@ -25,79 +25,20 @@ namespace FlaxEditor.Surface.Archetypes
/// </summary> /// </summary>
internal enum MaterialNodeBoxes internal enum MaterialNodeBoxes
{ {
/// <summary>
/// The layer input.
/// </summary>
Layer = 0, Layer = 0,
/// <summary>
/// The color input.
/// </summary>
Color = 1, Color = 1,
/// <summary>
/// The mask input.
/// </summary>
Mask = 2, Mask = 2,
/// <summary>
/// The emissive input.
/// </summary>
Emissive = 3, Emissive = 3,
/// <summary>
/// The metalness input.
/// </summary>
Metalness = 4, Metalness = 4,
/// <summary>
/// The specular input.
/// </summary>
Specular = 5, Specular = 5,
/// <summary>
/// The roughness input.
/// </summary>
Roughness = 6, Roughness = 6,
/// <summary>
/// The ambient occlusion input.
/// </summary>
AmbientOcclusion = 7, AmbientOcclusion = 7,
/// <summary>
/// The normal input.
/// </summary>
Normal = 8, Normal = 8,
/// <summary>
/// The opacity input.
/// </summary>
Opacity = 9, Opacity = 9,
/// <summary>
/// The refraction input.
/// </summary>
Refraction = 10, Refraction = 10,
/// <summary>
/// The position offset input.
/// </summary>
PositionOffset = 11, PositionOffset = 11,
/// <summary>
/// The tessellation multiplier input.
/// </summary>
TessellationMultiplier = 12, TessellationMultiplier = 12,
/// <summary>
/// The world displacement input.
/// </summary>
WorldDisplacement = 13, WorldDisplacement = 13,
/// <summary>
/// The subsurface color input.
/// </summary>
SubsurfaceColor = 14, SubsurfaceColor = 14,
}; };
@@ -159,7 +100,6 @@ namespace FlaxEditor.Surface.Archetypes
case MaterialDomain.Deformable: case MaterialDomain.Deformable:
{ {
bool isNotUnlit = info.ShadingModel != MaterialShadingModel.Unlit; bool isNotUnlit = info.ShadingModel != MaterialShadingModel.Unlit;
bool isTransparent = info.BlendMode == MaterialBlendMode.Transparent;
bool withTess = info.TessellationMode != TessellationMethod.None; bool withTess = info.TessellationMode != TessellationMethod.None;
GetBox(MaterialNodeBoxes.Color).Enabled = isNotUnlit; GetBox(MaterialNodeBoxes.Color).Enabled = isNotUnlit;
@@ -171,7 +111,7 @@ namespace FlaxEditor.Surface.Archetypes
GetBox(MaterialNodeBoxes.AmbientOcclusion).Enabled = isNotUnlit; GetBox(MaterialNodeBoxes.AmbientOcclusion).Enabled = isNotUnlit;
GetBox(MaterialNodeBoxes.Normal).Enabled = isNotUnlit; GetBox(MaterialNodeBoxes.Normal).Enabled = isNotUnlit;
GetBox(MaterialNodeBoxes.Opacity).Enabled = info.ShadingModel == MaterialShadingModel.Subsurface || info.ShadingModel == MaterialShadingModel.Foliage || info.BlendMode != MaterialBlendMode.Opaque; GetBox(MaterialNodeBoxes.Opacity).Enabled = info.ShadingModel == MaterialShadingModel.Subsurface || info.ShadingModel == MaterialShadingModel.Foliage || info.BlendMode != MaterialBlendMode.Opaque;
GetBox(MaterialNodeBoxes.Refraction).Enabled = isTransparent; GetBox(MaterialNodeBoxes.Refraction).Enabled = info.BlendMode != MaterialBlendMode.Opaque;
GetBox(MaterialNodeBoxes.PositionOffset).Enabled = true; GetBox(MaterialNodeBoxes.PositionOffset).Enabled = true;
GetBox(MaterialNodeBoxes.TessellationMultiplier).Enabled = withTess; GetBox(MaterialNodeBoxes.TessellationMultiplier).Enabled = withTess;
GetBox(MaterialNodeBoxes.WorldDisplacement).Enabled = withTess; GetBox(MaterialNodeBoxes.WorldDisplacement).Enabled = withTess;

View File

@@ -422,12 +422,19 @@ void AnimatedModel::UpdateLocalBounds()
//box = SkinnedModel->GetBox(GraphInstance.RootTransform.GetWorld()); //box = SkinnedModel->GetBox(GraphInstance.RootTransform.GetWorld());
//box = SkinnedModel->GetBox(); //box = SkinnedModel->GetBox();
// Per-bone bounds estimated from positions if (GraphInstance.NodesPose.Count() != 0)
auto& skeleton = SkinnedModel->Skeleton; {
const int32 bonesCount = skeleton.Bones.Count(); // Per-bone bounds estimated from positions
box = BoundingBox(GraphInstance.NodesPose[skeleton.Bones[0].NodeIndex].GetTranslation()); auto& skeleton = SkinnedModel->Skeleton;
for (int32 boneIndex = 1; boneIndex < bonesCount; boneIndex++) const int32 bonesCount = skeleton.Bones.Count();
box.Merge(GraphInstance.NodesPose[skeleton.Bones[boneIndex].NodeIndex].GetTranslation()); box = BoundingBox(GraphInstance.NodesPose[skeleton.Bones[0].NodeIndex].GetTranslation());
for (int32 boneIndex = 1; boneIndex < bonesCount; boneIndex++)
box.Merge(GraphInstance.NodesPose[skeleton.Bones[boneIndex].NodeIndex].GetTranslation());
}
else
{
box = SkinnedModel->GetBox();
}
// Apply margin based on model dimensions // Apply margin based on model dimensions
const Vector3 modelBoxSize = SkinnedModel->GetBox().GetSize(); const Vector3 modelBoxSize = SkinnedModel->GetBox().GetSize();