feat: modules moved and engine moved to submodule
This commit is contained in:
parent
dfb5e645cd
commit
c33d2130cc
5136 changed files with 225275 additions and 64485 deletions
|
|
@ -464,7 +464,9 @@ bool Animation::_get(const StringName &p_name, Variant &r_ret) const {
|
|||
String prop_name = p_name;
|
||||
|
||||
if (p_name == SNAME("_compression")) {
|
||||
ERR_FAIL_COND_V(!compression.enabled, false);
|
||||
if (!compression.enabled) {
|
||||
return false;
|
||||
}
|
||||
Dictionary comp;
|
||||
comp["fps"] = compression.fps;
|
||||
Array bounds;
|
||||
|
|
@ -2476,7 +2478,7 @@ Variant Animation::_interpolate_angle(const Variant &p_a, const Variant &p_b, re
|
|||
if (vformat == ((1 << Variant::INT) | (1 << Variant::FLOAT)) || vformat == (1 << Variant::FLOAT)) {
|
||||
real_t a = p_a;
|
||||
real_t b = p_b;
|
||||
return Math::fposmod((float)Math::lerp_angle(a, b, p_c), (float)Math_TAU);
|
||||
return Math::fposmod((float)Math::lerp_angle(a, b, p_c), (float)Math::TAU);
|
||||
}
|
||||
return _interpolate(p_a, p_b, p_c);
|
||||
}
|
||||
|
|
@ -2513,7 +2515,7 @@ Variant Animation::_cubic_interpolate_angle_in_time(const Variant &p_pre_a, cons
|
|||
real_t b = p_b;
|
||||
real_t pa = p_pre_a;
|
||||
real_t pb = p_post_b;
|
||||
return Math::fposmod((float)Math::cubic_interpolate_angle_in_time(a, b, pa, pb, p_c, p_b_t, p_pre_a_t, p_post_b_t), (float)Math_TAU);
|
||||
return Math::fposmod((float)Math::cubic_interpolate_angle_in_time(a, b, pa, pb, p_c, p_b_t, p_pre_a_t, p_post_b_t), (float)Math::TAU);
|
||||
}
|
||||
return _cubic_interpolate_in_time(p_pre_a, p_a, p_b, p_post_b, p_c, p_pre_a_t, p_b_t, p_post_b_t);
|
||||
}
|
||||
|
|
@ -4207,7 +4209,7 @@ bool Animation::_quaternion_track_optimize_key(const TKey<Quaternion> t0, const
|
|||
if (q0.get_axis().dot(q1.get_axis()) >= 1.0 - p_allowed_angular_error * 2.0) {
|
||||
double a0 = Math::acos(t0.value.dot(t1.value));
|
||||
double a1 = Math::acos(t1.value.dot(t2.value));
|
||||
if (a0 + a1 >= Math_PI / 2) {
|
||||
if (a0 + a1 >= Math::PI / 2) {
|
||||
return false; // Rotation is more than 180 deg, keep key.
|
||||
}
|
||||
// Calc velocities.
|
||||
|
|
@ -4335,7 +4337,7 @@ void Animation::_value_track_optimize(int p_idx, real_t p_allowed_velocity_err,
|
|||
ERR_FAIL_INDEX(p_idx, tracks.size());
|
||||
ERR_FAIL_COND(tracks[p_idx]->type != TYPE_VALUE);
|
||||
ValueTrack *vt = static_cast<ValueTrack *>(tracks[p_idx]);
|
||||
if (vt->values.size() == 0) {
|
||||
if (vt->values.is_empty()) {
|
||||
return;
|
||||
}
|
||||
Variant::Type type = vt->values[0].value.get_type();
|
||||
|
|
@ -4357,11 +4359,11 @@ void Animation::_value_track_optimize(int p_idx, real_t p_allowed_velocity_err,
|
|||
t1.value = vt->values[i + 1].value;
|
||||
t2.value = vt->values[i + 2].value;
|
||||
if (is_using_angle) {
|
||||
float diff1 = fmod(t1.value - t0.value, Math_TAU);
|
||||
t1.value = t0.value + fmod(2.0 * diff1, Math_TAU) - diff1;
|
||||
float diff2 = fmod(t2.value - t1.value, Math_TAU);
|
||||
t2.value = t1.value + fmod(2.0 * diff2, Math_TAU) - diff2;
|
||||
if (abs(abs(diff1) + abs(diff2)) >= Math_PI) {
|
||||
float diff1 = fmod(t1.value - t0.value, Math::TAU);
|
||||
t1.value = t0.value + fmod(2.0 * diff1, Math::TAU) - diff1;
|
||||
float diff2 = fmod(t2.value - t1.value, Math::TAU);
|
||||
t2.value = t1.value + fmod(2.0 * diff2, Math::TAU) - diff2;
|
||||
if (abs(abs(diff1) + abs(diff2)) >= Math::PI) {
|
||||
break; // Rotation is more than 180 deg, keep key.
|
||||
}
|
||||
}
|
||||
|
|
@ -4421,8 +4423,8 @@ void Animation::_value_track_optimize(int p_idx, real_t p_allowed_velocity_err,
|
|||
float val_0 = vt->values[0].value;
|
||||
float val_1 = vt->values[1].value;
|
||||
if (is_using_angle) {
|
||||
float diff1 = fmod(val_1 - val_0, Math_TAU);
|
||||
val_1 = val_0 + fmod(2.0 * diff1, Math_TAU) - diff1;
|
||||
float diff1 = fmod(val_1 - val_0, Math::TAU);
|
||||
val_1 = val_0 + fmod(2.0 * diff1, Math::TAU) - diff1;
|
||||
}
|
||||
single_key = abs(val_0 - val_1) < p_allowed_precision_error;
|
||||
} break;
|
||||
|
|
@ -4507,7 +4509,7 @@ struct AnimationCompressionDataState {
|
|||
if (p_delta == 0) {
|
||||
return 0;
|
||||
} else if (p_delta < 0) {
|
||||
p_delta = ABS(p_delta) - 1;
|
||||
p_delta = Math::abs(p_delta) - 1;
|
||||
if (p_delta == 0) {
|
||||
return 1;
|
||||
}
|
||||
|
|
@ -4582,7 +4584,7 @@ struct AnimationCompressionDataState {
|
|||
}
|
||||
|
||||
uint32_t get_temp_packet_size() const {
|
||||
if (temp_packets.size() == 0) {
|
||||
if (temp_packets.is_empty()) {
|
||||
return 0;
|
||||
} else if (temp_packets.size() == 1) {
|
||||
return components == 1 ? 4 : 8; // 1 component packet is 16 bits and 16 bits unused. 3 component packets is 48 bits and 16 bits unused
|
||||
|
|
@ -4624,7 +4626,7 @@ struct AnimationCompressionDataState {
|
|||
}
|
||||
|
||||
void commit_temp_packets() {
|
||||
if (temp_packets.size() == 0) {
|
||||
if (temp_packets.is_empty()) {
|
||||
return; // Nothing to do.
|
||||
}
|
||||
//#define DEBUG_PACKET_PUSH
|
||||
|
|
@ -4689,7 +4691,7 @@ struct AnimationCompressionDataState {
|
|||
|
||||
uint16_t deltau;
|
||||
if (delta < 0) {
|
||||
deltau = (ABS(delta) - 1) | (1 << max_shifts[j]);
|
||||
deltau = (Math::abs(delta) - 1) | (1 << max_shifts[j]);
|
||||
} else {
|
||||
deltau = delta;
|
||||
}
|
||||
|
|
@ -4754,9 +4756,9 @@ Vector3i Animation::_compress_key(uint32_t p_track, const AABB &p_bounds, int32_
|
|||
}
|
||||
Vector3 axis = rot.get_axis();
|
||||
float angle = rot.get_angle();
|
||||
angle = Math::fposmod(double(angle), double(Math_PI * 2.0));
|
||||
angle = Math::fposmod(double(angle), double(Math::PI * 2.0));
|
||||
Vector2 oct = axis.octahedron_encode();
|
||||
Vector3 rot_norm(oct.x, oct.y, angle / (Math_PI * 2.0)); // high resolution rotation in 0-1 angle.
|
||||
Vector3 rot_norm(oct.x, oct.y, angle / (Math::PI * 2.0)); // high resolution rotation in 0-1 angle.
|
||||
|
||||
for (int j = 0; j < 3; j++) {
|
||||
values[j] = CLAMP(int32_t(rot_norm[j] * 65535.0), 0, 65535);
|
||||
|
|
@ -4890,7 +4892,7 @@ void Animation::compress(uint32_t p_page_size, uint32_t p_fps, float p_split_tol
|
|||
track_bounds.push_back(bounds);
|
||||
}
|
||||
|
||||
if (tracks_to_compress.size() == 0) {
|
||||
if (tracks_to_compress.is_empty()) {
|
||||
return; //nothing to compress
|
||||
}
|
||||
|
||||
|
|
@ -5045,7 +5047,7 @@ void Animation::compress(uint32_t p_page_size, uint32_t p_fps, float p_split_tol
|
|||
uint32_t total_page_size = 0;
|
||||
|
||||
for (uint32_t i = 0; i < data_tracks.size(); i++) {
|
||||
if (data_tracks[i].temp_packets.size() == 0 || (data_tracks[i].temp_packets[data_tracks[i].temp_packets.size() - 1].frame) < finalizer_local_frame) {
|
||||
if (data_tracks[i].temp_packets.is_empty() || (data_tracks[i].temp_packets[data_tracks[i].temp_packets.size() - 1].frame) < finalizer_local_frame) {
|
||||
// Add finalizer frame if it makes sense
|
||||
Vector3i values = _compress_key(tracks_to_compress[i], track_bounds[i], -1, page_end_frame * frame_len);
|
||||
|
||||
|
|
@ -5532,7 +5534,7 @@ int Animation::_get_compressed_key_count(uint32_t p_compressed_track) const {
|
|||
|
||||
Quaternion Animation::_uncompress_quaternion(const Vector3i &p_value) const {
|
||||
Vector3 axis = Vector3::octahedron_decode(Vector2(float(p_value.x) / 65535.0, float(p_value.y) / 65535.0));
|
||||
float angle = (float(p_value.z) / 65535.0) * 2.0 * Math_PI;
|
||||
float angle = (float(p_value.z) / 65535.0) * 2.0 * Math::PI;
|
||||
return Quaternion(axis, angle);
|
||||
}
|
||||
Vector3 Animation::_uncompress_pos_scale(uint32_t p_compressed_track, const Vector3i &p_value) const {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue