Hi.
I finally have the class UNewtonCollisionPrimitive : public UDynamicMeshComponent
working more or less as I want it. however still has some problems that I can’t find a solution for.
the video bellow show what I mean
as you can see, the Mesh works in the editor, I can change the size of all of the Uproperties.
The problem is that I do not knwo how to make the editor recognize the changes made in the c++ code.
This is very important for us, because as you can see, trying to match the size for the shape by editing the primitive size to the staticMeshComponent is not an eassy thing, specially when staticMeshComponent do not provides editor info about size.
I tried do do it on initialization but at that time not all info is ready, basically a UClass can not have other UClass dependent default values, which seems reasonable to me.
So, I figured I can add a bottom, that the user can click, and in code, It used the parent mesh bounds to calculate matching Uproperties.
This gives the user a better starting point for further tweaks.
In the video you can see that this works fine, expect that the Uproperties do not get refresh to the new values, as a long as I never modify the Uproperties proceduratly.
As soon as I apply the best fit option, for some reason, the new Uproperties are stored in component or in some database, and not matter what the component can not be edited from that point on, even if I quit the map and reload it.
The only way to edit is by deleting the components and starting over.
I have debugged this for several days, also rewrote the code several times, but it is the same problem problem or worse.
Does anyone knows what do I need to do to make teh editor award that some UProperties where
modifies procedurally?
the code that implement that Bound calculation is quite simple, it is just this.
void UNewtonCollisionPrimitiveBox::ApplyPropertyChanges()
{
if (BestFit)
{
for (USceneComponent* parent = GetAttachParent(); parent; parent = parent->GetAttachParent())
{
UStaticMeshComponent* const meshComp = Cast<UStaticMeshComponent>(parent);
if (meshComp && meshComp->GetStaticMesh())
{
FBoxSphereBounds bounds(meshComp->CalcBounds(FTransform()));
SizeX = ndMax(float(bounds.BoxExtent.X * 2.0f), 2.0f);
SizeY = ndMax(float(bounds.BoxExtent.Y * 2.0f), 2.0f);
SizeZ = ndMax(float(bounds.BoxExtent.Z * 2.0f), 2.0f);
SetRelativeTransform(FTransform());
break;
}
}
}
BuildNewtonShape();
Super::ApplyPropertyChanges();
}
Thanks.