Skip to content

Commit a73e477

Browse files
committed
batch value grab for properties/pathproperties
1 parent e81ddc0 commit a73e477

File tree

3 files changed

+274
-14
lines changed

3 files changed

+274
-14
lines changed

shared/Animation/Track.h

Lines changed: 190 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,168 @@ struct PathPropertyW {
255255
// Tracks::ffi::path_property_init(property, newPointData.value_or(PointDefinitionW(nullptr)));
256256
// }
257257
};
258+
struct PropertiesMapW {
259+
PropertiesMapW(Tracks::ffi::CPropertiesMap map)
260+
: position(map.position), rotation(map.rotation), scale(map.scale), localRotation(map.local_rotation),
261+
localPosition(map.local_position), dissolve(map.dissolve), dissolveArrow(map.dissolve_arrow), time(map.time),
262+
cuttable(map.cuttable), color(map.color), attentuation(map.attentuation), fogOffset(map.fog_offset),
263+
heightFogStartY(map.height_fog_start_y), heightFogHeight(map.height_fog_height) {}
264+
265+
PropertyW position;
266+
PropertyW rotation;
267+
PropertyW scale;
268+
PropertyW localRotation;
269+
PropertyW localPosition;
270+
PropertyW dissolve;
271+
PropertyW dissolveArrow;
272+
PropertyW time;
273+
PropertyW cuttable;
274+
PropertyW color;
275+
PropertyW attentuation;
276+
PropertyW fogOffset;
277+
PropertyW heightFogStartY;
278+
PropertyW heightFogHeight;
279+
};
280+
281+
struct PathPropertiesMapW {
282+
PathPropertiesMapW(Tracks::ffi::CPathPropertiesMap map,
283+
std::shared_ptr<TracksAD::BaseProviderContextW> internal_tracks_context)
284+
: position(map.position, internal_tracks_context), rotation(map.rotation, internal_tracks_context),
285+
scale(map.scale, internal_tracks_context), localRotation(map.local_rotation, internal_tracks_context),
286+
localPosition(map.local_position, internal_tracks_context),
287+
definitePosition(map.definite_position, internal_tracks_context),
288+
dissolve(map.dissolve, internal_tracks_context), dissolveArrow(map.dissolve_arrow, internal_tracks_context),
289+
cuttable(map.cuttable, internal_tracks_context), color(map.color, internal_tracks_context) {}
290+
291+
PathPropertyW position;
292+
PathPropertyW rotation;
293+
PathPropertyW scale;
294+
PathPropertyW localRotation;
295+
PathPropertyW localPosition;
296+
PathPropertyW definitePosition;
297+
PathPropertyW dissolve;
298+
PathPropertyW dissolveArrow;
299+
PathPropertyW cuttable;
300+
PathPropertyW color;
301+
};
302+
303+
struct PropertiesValuesW {
304+
constexpr PropertiesValuesW(Tracks::ffi::CPropertiesValues values) {
305+
if (values.position.has_value) {
306+
position = NEVector::Vector3{ values.position.value.x, values.position.value.y, values.position.value.z };
307+
}
308+
if (values.rotation.has_value) {
309+
rotation = NEVector::Quaternion{ values.rotation.value.x, values.rotation.value.y, values.rotation.value.z,
310+
values.rotation.value.w };
311+
}
312+
if (values.scale.has_value) {
313+
scale = NEVector::Vector3{ values.scale.value.x, values.scale.value.y, values.scale.value.z };
314+
}
315+
if (values.local_rotation.has_value) {
316+
localRotation = NEVector::Quaternion{ values.local_rotation.value.x, values.local_rotation.value.y,
317+
values.local_rotation.value.z, values.local_rotation.value.w };
318+
}
319+
if (values.local_position.has_value) {
320+
localPosition =
321+
NEVector::Vector3{ values.local_position.value.x, values.local_position.value.y,
322+
values.local_position.value.z };
323+
}
324+
if (values.dissolve.has_value) {
325+
dissolve = values.dissolve.value;
326+
}
327+
if (values.dissolve_arrow.has_value) {
328+
dissolveArrow = values.dissolve_arrow.value;
329+
}
330+
if (values.time.has_value) {
331+
time = values.time.value;
332+
}
333+
if (values.cuttable.has_value) {
334+
cuttable = values.cuttable.value;
335+
}
336+
if (values.color.has_value) {
337+
color = NEVector::Vector4{ values.color.value.x, values.color.value.y, values.color.value.z,
338+
values.color.value.w };
339+
}
340+
if (values.attentuation.has_value) {
341+
attentuation = values.attentuation.value;
342+
}
343+
if (values.fog_offset.has_value) {
344+
fogOffset = values.fog_offset.value;
345+
}
346+
if (values.height_fog_start_y.has_value) {
347+
heightFogStartY = values.height_fog_start_y.value;
348+
}
349+
if (values.height_fog_height.has_value) {
350+
heightFogHeight = values.height_fog_height.value;
351+
}
352+
}
353+
354+
std::optional<NEVector::Vector3> position;
355+
std::optional<NEVector::Quaternion> rotation;
356+
std::optional<NEVector::Vector3> scale;
357+
std::optional<NEVector::Quaternion> localRotation;
358+
std::optional<NEVector::Vector3> localPosition;
359+
std::optional<float> dissolve;
360+
std::optional<float> dissolveArrow;
361+
std::optional<float> time;
362+
std::optional<float> cuttable;
363+
std::optional<NEVector::Vector4> color;
364+
std::optional<float> attentuation;
365+
std::optional<float> fogOffset;
366+
std::optional<float> heightFogStartY;
367+
std::optional<float> heightFogHeight;
368+
};
369+
370+
struct PathPropertiesValuesW {
371+
constexpr PathPropertiesValuesW(Tracks::ffi::CPathPropertiesValues values) {
372+
if (values.position.has_value) {
373+
position = NEVector::Vector3{ values.position.value.x, values.position.value.y, values.position.value.z };
374+
}
375+
if (values.rotation.has_value) {
376+
rotation = NEVector::Quaternion{ values.rotation.value.x, values.rotation.value.y, values.rotation.value.z,
377+
values.rotation.value.w };
378+
}
379+
if (values.scale.has_value) {
380+
scale = NEVector::Vector3{ values.scale.value.x, values.scale.value.y, values.scale.value.z };
381+
}
382+
if (values.local_rotation.has_value) {
383+
localRotation = NEVector::Quaternion{ values.local_rotation.value.x, values.local_rotation.value.y,
384+
values.local_rotation.value.z, values.local_rotation.value.w };
385+
}
386+
if (values.local_position.has_value) {
387+
localPosition =
388+
NEVector::Vector3{ values.local_position.value.x, values.local_position.value.y,
389+
values.local_position.value.z };
390+
}
391+
if (values.definite_position.has_value) {
392+
definitePosition = values.definite_position.value;
393+
}
394+
if (values.dissolve.has_value) {
395+
dissolve = values.dissolve.value;
396+
}
397+
if (values.dissolve_arrow.has_value) {
398+
dissolveArrow = values.dissolve_arrow.value;
399+
}
400+
if (values.cuttable.has_value) {
401+
cuttable = values.cuttable.value;
402+
}
403+
if (values.color.has_value) {
404+
color = NEVector::Vector4{ values.color.value.x, values.color.value.y, values.color.value.z,
405+
values.color.value.w };
406+
}
407+
}
408+
409+
std::optional<NEVector::Vector3> position;
410+
std::optional<NEVector::Quaternion> rotation;
411+
std::optional<NEVector::Vector3> scale;
412+
std::optional<NEVector::Quaternion> localRotation;
413+
std::optional<NEVector::Vector3> localPosition;
414+
std::optional<float> definitePosition;
415+
std::optional<float> dissolve;
416+
std::optional<float> dissolveArrow;
417+
std::optional<float> cuttable;
418+
std::optional<NEVector::Vector4> color;
419+
};
258420

259421
struct TrackW {
260422
Tracks::ffi::TrackKeyFFI track = Tracks::ffi::TrackKeyFFI{ static_cast<uint64_t>(-1) };
@@ -331,6 +493,34 @@ struct TrackW {
331493
return PathPropertyW(prop, base_provider_context);
332494
}
333495

496+
[[nodiscard]]
497+
PropertiesMapW GetPropertiesMapW() const {
498+
auto track = getTrackPtr();
499+
auto map = Tracks::ffi::track_get_properties_map(track);
500+
return PropertiesMapW(map);
501+
}
502+
503+
[[nodiscard]]
504+
PathPropertiesMapW GetPathPropertiesMapW() const {
505+
auto track = getTrackPtr();
506+
auto map = Tracks::ffi::track_get_path_properties_map(track);
507+
return PathPropertiesMapW(map, base_provider_context);
508+
}
509+
510+
[[nodiscard]]
511+
PropertiesValuesW GetPropertiesValuesW() const {
512+
auto track = getTrackPtr();
513+
auto values = Tracks::ffi::track_get_properties_values(track);
514+
return PropertiesValuesW(values);
515+
}
516+
517+
[[nodiscard]]
518+
PathPropertiesValuesW GetPathPropertiesValuesW(float time) const {
519+
auto track = getTrackPtr();
520+
auto values = Tracks::ffi::track_get_path_properties_values(track, time, *base_provider_context);
521+
return PathPropertiesValuesW(values);
522+
}
523+
334524
void RegisterGameObject(UnityEngine::GameObject* gameObject) const {
335525
auto ptr = getTrackPtr();
336526
Tracks::ffi::track_register_game_object(ptr, Tracks::ffi::GameObject{ .ptr = gameObject });

shared/bindings.h

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,56 @@ typedef struct CPathPropertiesMap {
310310
PathProperty *color;
311311
} CPathPropertiesMap;
312312

313+
typedef struct Vec3Option {
314+
struct WrapVec3 value;
315+
bool has_value;
316+
} Vec3Option;
317+
318+
typedef struct QuatOption {
319+
struct WrapQuat value;
320+
bool has_value;
321+
} QuatOption;
322+
323+
typedef struct FloatOption {
324+
float value;
325+
bool has_value;
326+
} FloatOption;
327+
328+
typedef struct Vec4Option {
329+
struct WrapVec4 value;
330+
bool has_value;
331+
} Vec4Option;
332+
333+
typedef struct CPropertiesValues {
334+
struct Vec3Option position;
335+
struct QuatOption rotation;
336+
struct Vec3Option scale;
337+
struct QuatOption local_rotation;
338+
struct Vec3Option local_position;
339+
struct FloatOption dissolve;
340+
struct FloatOption dissolve_arrow;
341+
struct FloatOption time;
342+
struct FloatOption cuttable;
343+
struct Vec4Option color;
344+
struct FloatOption attentuation;
345+
struct FloatOption fog_offset;
346+
struct FloatOption height_fog_start_y;
347+
struct FloatOption height_fog_height;
348+
} CPropertiesValues;
349+
350+
typedef struct CPathPropertiesValues {
351+
struct Vec3Option position;
352+
struct QuatOption rotation;
353+
struct Vec3Option scale;
354+
struct QuatOption local_rotation;
355+
struct Vec3Option local_position;
356+
struct FloatOption definite_position;
357+
struct FloatOption dissolve;
358+
struct FloatOption dissolve_arrow;
359+
struct FloatOption cuttable;
360+
struct Vec4Option color;
361+
} CPathPropertiesValues;
362+
313363
typedef void (*CGameObjectCallback)(struct GameObject, bool, void*);
314364

315365

@@ -900,6 +950,26 @@ struct CPropertiesMap track_get_properties_map(struct Track *track);
900950
*/
901951
struct CPathPropertiesMap track_get_path_properties_map(struct Track *track);
902952

953+
/**
954+
* Return a `CPropertiesValues` with the current values of the track's properties.
955+
* - `track` must be a valid, non-null pointer to a `Track
956+
* - The returned struct contains copies of the current property values.
957+
*/
958+
struct CPropertiesValues track_get_properties_values(struct Track *track);
959+
960+
/**
961+
* Return a `CPathPropertiesValues` with the interpolated values of the track's path properties at the given time.
962+
* Safety:
963+
* - `track` must be a valid, non-null pointer to a `Track`.
964+
* - `ctx` must be a valid, non-null pointer to a `BaseProviderContext`.
965+
*
966+
* - The returned struct contains copies of the interpolated property values.
967+
*
968+
*/
969+
struct CPathPropertiesValues track_get_path_properties_values(struct Track *track,
970+
float time,
971+
const struct BaseProviderContext *ctx);
972+
903973
/**
904974
* Register a C callback to be invoked when a game object is added/removed.
905975
*

tracks_rs_link/Cargo.lock

Lines changed: 14 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)