Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for setting/getting 3D world position of text and attaching text to ObjectReference #1504

Open
Pospelove opened this issue Jun 27, 2023 · 1 comment
Assignees

Comments

@Pospelove
Copy link
Contributor

Description:

We currently have support for creating, manipulating, and fetching various attributes of 2D text elements in our application, but there is a need to further extend this functionality. Specifically, we need to enable users to:

Set and get the 3D position of a text element in the world space.
Attach a text element to an ObjectReference, optionally specifying a node (e.g., head node) and a 3D offset from the specified node.

This API, when will be used, will help our client survive in case of 100-1000 objects/players with nicknmaes without significant performance loss. The main thing is that we move texts draw logic from JavaScript to C++

Implementation Details:

This requires the addition of the following methods:

setTextPos3D(textId: number, pos: number[]): void;
getTextPos3D(textId: number): number[];
attachTextToObject(textId: number, objectReference: ObjectReference, node?: string, offset?: number[]): void;
setDrawDistance(textId: number, drawDistance: number): void;
getDrawDistance(textId: number): number;

Corner Cases:

There are several considerations and potential corner cases that should be kept in mind:

  • For attaching a text to a node, we need to handle cases where the specified node doesn't exist or is not valid. A graceful error message should be provided in such cases.

  • The 3D offset should default to [0,0,0] if not provided.

  • We need to handle the situation where the ObjectReference does not exist or is no longer valid: text should become invisible but still being in "attached" state, still not destroyed (??) (I'm not sure, we can discuss that later). (The object is no longer valid if LookupFormById(refrId) != refr. So it's now nullptr OR changed.)

  • If a text element is attached to an ObjectReference and the object moves, the text should update its position accordingly.

  • If a text is attached to an object and the text's position is manually set afterward, the attachment should be broken to avoid inconsistencies.

  • The text with 3D pos set should be visible only if Z-coordinate on the screen is >= 0

  • The text attached to ObjectReference should be visible only Z-coordinate on the screen is >= 0 AND HasLos(objectReference) == true

  • If (localPlayerPos - text pos).Length() > drawDistance, text should not be visible

Documentation:

All new functions should be fully documented. Also, usage examples should be provided. + changelog

depends on #1503

See also

https://github.com/skyrim-multiplayer/skymp/blob/82e4d2fc5c4d3601036bd7686f56932260a0cd1a/skymp5-client/src/view/formView.ts#L390C56-L390C56

Copy link
Contributor

github-actions bot commented Apr 9, 2024

This PR/issue depends on:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants