Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions include/RED4ext/Scripting/Natives/entIPlacedComponent.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,30 @@ struct __declspec(align(0x10)) IPlacedComponent : ent::IComponent
static constexpr const char* NAME = "entIPlacedComponent";
static constexpr const char* ALIAS = "IPlacedComponent";

struct ChildBinding
{
Handle<ent::IComponent> component; // 00
Handle<ent::IAttachment> attachment; // 10
};

Handle<ent::ITransformBinding> parentTransform; // 90
uint8_t unkA0[0xC0 - 0xA0]; // A0
DynArray<ChildBinding> childrenTransforms; // A0
uint8_t unkB0[0xC0 - 0xB0]; // B0
WorldTransform localTransform; // C0
WorldTransform worldTransform; // E0
uint8_t unkE0[0x120 - 0x100]; // 100
Vector4 lastPosition; // 100

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What would lastPosition mean in this context? Can the component move itself?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

position should be equal to worldTransform, but with different precision due to float / FixedPoint conversion.
lastPosition seems to be a tick/frame in the past regarding position.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just my though: currentPosition / previousPosition seems more understandable then position / lastPosition

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I wasn't sure about the naming. I'll change it when I'll have another go with RedMemoryDump to record "frames" at a faster tick rate and confirm handle type.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems odd that position is stored twice. For non moving, non animated entity the transform and both positions are always the same?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hum, I'll check those.
But Vector4 values clearly shows valid coordinates and seems a tick behind.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIRC working on RHT, I've seen a lot of zeroes there for visual components. Which component type are you testing right now?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TransformComponent from a gamePuppet.

@poirierlouis poirierlouis Nov 29, 2025

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I checked the constructor of IPlacedComponent (hash 3069184773).
It contains:

[this + 0x100] = 7F7FFFFF7F7FFFFF7F7FFFFF7F7FFFFF
[this + 0x110] = FF7FFFFFFF7FFFFFFF7FFFFFFF7FFFFF

So it gives us:

Vector4 previousPosition = Vector4(NaN, NaN, NaN, NaN);
Vector4 currentPosition = Vector4(NaN, NaN, NaN, NaN);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's a Box.

Vector4 position; // 110
};
RED4EXT_ASSERT_SIZE(IPlacedComponent::ChildBinding, 0x20);
RED4EXT_ASSERT_OFFSET(IPlacedComponent::ChildBinding, component, 0x00);
RED4EXT_ASSERT_OFFSET(IPlacedComponent::ChildBinding, attachment, 0x10);

RED4EXT_ASSERT_SIZE(IPlacedComponent, 0x120);
RED4EXT_ASSERT_OFFSET(IPlacedComponent, parentTransform, 0x90);
RED4EXT_ASSERT_OFFSET(IPlacedComponent, localTransform, 0xC0);
RED4EXT_ASSERT_OFFSET(IPlacedComponent, worldTransform, 0xE0);
RED4EXT_ASSERT_OFFSET(IPlacedComponent, lastPosition, 0x100);
RED4EXT_ASSERT_OFFSET(IPlacedComponent, position, 0x110);
} // namespace ent
using entIPlacedComponent = ent::IPlacedComponent;
using IPlacedComponent = ent::IPlacedComponent;
Expand Down