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

Anim speed #228

Merged
merged 12 commits into from
Dec 5, 2023
4 changes: 4 additions & 0 deletions xml_converter/doc/texture/animation_speed.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ type: Float32
applies_to: [Trail]
xml_fields: ["AnimSpeed", "AnimationSpeed"]
protobuf_field: animation_speed
custom_functions:
read.xml:
function: default_value_one_xml_attribute_to_float
side_effects: []
---
The speed which the texture should be moving across the object.

Expand Down
Copy link

Choose a reason for hiding this comment

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

Full Diff
--- xml_converter/intigration_tests/expected_outputs/proto_animation_speed/markers.bin.textproto._old	2023-12-03 21:09:20.738595640 +0000
+++ xml_converter/intigration_tests/expected_outputs/proto_animation_speed/markers.bin.textproto._new	2023-12-03 21:09:20.746595627 +0000
@@ -0,0 +1,35 @@
+category {
+  name: "My Category"
+  trail {
+  }
+  trail {
+  }
+  trail {
+    animation_speed: 3.14
+  }
+  trail {
+    animation_speed: 123.456
+  }
+  trail {
+  }
+  trail {
+  }
+  trail {
+    animation_speed: 3.14
+  }
+  trail {
+    animation_speed: 123.456
+  }
+  trail {
+    animation_speed: -3.14
+  }
+  trail {
+    animation_speed: -123.456
+  }
+  trail {
+    animation_speed: -3.14
+  }
+  trail {
+    animation_speed: -123.456
+  }
+}

Copy link

Choose a reason for hiding this comment

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

Full Diff
--- xml_converter/intigration_tests/expected_outputs/proto_animation_speed/markers.bin.textproto._old	2023-12-03 21:10:27.535470994 +0000
+++ xml_converter/intigration_tests/expected_outputs/proto_animation_speed/markers.bin.textproto._new	2023-12-03 21:10:27.543471044 +0000
@@ -0,0 +1,35 @@
+category {
+  name: "My Category"
+  trail {
+  }
+  trail {
+  }
+  trail {
+    animation_speed: 3.14
+  }
+  trail {
+    animation_speed: 123.456
+  }
+  trail {
+  }
+  trail {
+  }
+  trail {
+    animation_speed: 3.14
+  }
+  trail {
+    animation_speed: 123.456
+  }
+  trail {
+    animation_speed: -3.14
+  }
+  trail {
+    animation_speed: -123.456
+  }
+  trail {
+    animation_speed: -3.14
+  }
+  trail {
+    animation_speed: -123.456
+  }
+}

Copy link

Choose a reason for hiding this comment

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

Full Diff
--- xml_converter/intigration_tests/expected_outputs/proto_animation_speed/markers.bin.textproto._old	2023-12-04 03:28:00.138085994 +0000
+++ xml_converter/intigration_tests/expected_outputs/proto_animation_speed/markers.bin.textproto._new	2023-12-04 03:28:00.146085948 +0000
@@ -0,0 +1,179 @@
+category {
+  name: "My Category"
+  trail {
+    map_id: 50
+    trail_data {
+      points_x: 1
+      points_x: 2
+      points_x: 3
+      points_y: 4
+      points_y: 5
+      points_y: 6
+      points_z: 7
+      points_z: 8
+      points_z: 9
+    }
+  }
+  trail {
+    map_id: 50
+    trail_data {
+      points_x: 1
+      points_x: 2
+      points_x: 3
+      points_y: 4
+      points_y: 5
+      points_y: 6
+      points_z: 7
+      points_z: 8
+      points_z: 9
+    }
+  }
+  trail {
+    map_id: 50
+    trail_data {
+      points_x: 1
+      points_x: 2
+      points_x: 3
+      points_y: 4
+      points_y: 5
+      points_y: 6
+      points_z: 7
+      points_z: 8
+      points_z: 9
+    }
+    animation_speed: 3.14
+  }
+  trail {
+    map_id: 50
+    trail_data {
+      points_x: 1
+      points_x: 2
+      points_x: 3
+      points_y: 4
+      points_y: 5
+      points_y: 6
+      points_z: 7
+      points_z: 8
+      points_z: 9
+    }
+    animation_speed: 123.456
+  }
+  trail {
+    map_id: 50
+    trail_data {
+      points_x: 1
+      points_x: 2
+      points_x: 3
+      points_y: 4
+      points_y: 5
+      points_y: 6
+      points_z: 7
+      points_z: 8
+      points_z: 9
+    }
+  }
+  trail {
+    map_id: 50
+    trail_data {
+      points_x: 1
+      points_x: 2
+      points_x: 3
+      points_y: 4
+      points_y: 5
+      points_y: 6
+      points_z: 7
+      points_z: 8
+      points_z: 9
+    }
+  }
+  trail {
+    map_id: 50
+    trail_data {
+      points_x: 1
+      points_x: 2
+      points_x: 3
+      points_y: 4
+      points_y: 5
+      points_y: 6
+      points_z: 7
+      points_z: 8
+      points_z: 9
+    }
+    animation_speed: 3.14
+  }
+  trail {
+    map_id: 50
+    trail_data {
+      points_x: 1
+      points_x: 2
+      points_x: 3
+      points_y: 4
+      points_y: 5
+      points_y: 6
+      points_z: 7
+      points_z: 8
+      points_z: 9
+    }
+    animation_speed: 123.456
+  }
+  trail {
+    map_id: 50
+    trail_data {
+      points_x: 1
+      points_x: 2
+      points_x: 3
+      points_y: 4
+      points_y: 5
+      points_y: 6
+      points_z: 7
+      points_z: 8
+      points_z: 9
+    }
+    animation_speed: -3.14
+  }
+  trail {
+    map_id: 50
+    trail_data {
+      points_x: 1
+      points_x: 2
+      points_x: 3
+      points_y: 4
+      points_y: 5
+      points_y: 6
+      points_z: 7
+      points_z: 8
+      points_z: 9
+    }
+    animation_speed: -123.456
+  }
+  trail {
+    map_id: 50
+    trail_data {
+      points_x: 1
+      points_x: 2
+      points_x: 3
+      points_y: 4
+      points_y: 5
+      points_y: 6
+      points_z: 7
+      points_z: 8
+      points_z: 9
+    }
+    animation_speed: -3.14
+  }
+  trail {
+    map_id: 50
+    trail_data {
+      points_x: 1
+      points_x: 2
+      points_x: 3
+      points_y: 4
+      points_y: 5
+      points_y: 6
+      points_z: 7
+      points_z: 8
+      points_z: 9
+    }
+    animation_speed: -123.456
+  }
+}

Copy link

Choose a reason for hiding this comment

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

Full Diff
--- xml_converter/intigration_tests/expected_outputs/proto_animation_speed/markers.bin.textproto._old	2023-12-05 02:08:49.831166946 +0000
+++ xml_converter/intigration_tests/expected_outputs/proto_animation_speed/markers.bin.textproto._new	2023-12-05 02:08:49.839166935 +0000
@@ -0,0 +1,181 @@
+category {
+  name: "My Category"
+  trail {
+    map_id: 50
+    trail_data {
+      points_x: 1
+      points_x: 2
+      points_x: 3
+      points_y: 4
+      points_y: 5
+      points_y: 6
+      points_z: 7
+      points_z: 8
+      points_z: 9
+    }
+  }
+  trail {
+    map_id: 50
+    trail_data {
+      points_x: 1
+      points_x: 2
+      points_x: 3
+      points_y: 4
+      points_y: 5
+      points_y: 6
+      points_z: 7
+      points_z: 8
+      points_z: 9
+    }
+    animation_speed: 1
+  }
+  trail {
+    map_id: 50
+    trail_data {
+      points_x: 1
+      points_x: 2
+      points_x: 3
+      points_y: 4
+      points_y: 5
+      points_y: 6
+      points_z: 7
+      points_z: 8
+      points_z: 9
+    }
+    animation_speed: 3.14
+  }
+  trail {
+    map_id: 50
+    trail_data {
+      points_x: 1
+      points_x: 2
+      points_x: 3
+      points_y: 4
+      points_y: 5
+      points_y: 6
+      points_z: 7
+      points_z: 8
+      points_z: 9
+    }
+    animation_speed: 123.456
+  }
+  trail {
+    map_id: 50
+    trail_data {
+      points_x: 1
+      points_x: 2
+      points_x: 3
+      points_y: 4
+      points_y: 5
+      points_y: 6
+      points_z: 7
+      points_z: 8
+      points_z: 9
+    }
+  }
+  trail {
+    map_id: 50
+    trail_data {
+      points_x: 1
+      points_x: 2
+      points_x: 3
+      points_y: 4
+      points_y: 5
+      points_y: 6
+      points_z: 7
+      points_z: 8
+      points_z: 9
+    }
+    animation_speed: 1
+  }
+  trail {
+    map_id: 50
+    trail_data {
+      points_x: 1
+      points_x: 2
+      points_x: 3
+      points_y: 4
+      points_y: 5
+      points_y: 6
+      points_z: 7
+      points_z: 8
+      points_z: 9
+    }
+    animation_speed: 3.14
+  }
+  trail {
+    map_id: 50
+    trail_data {
+      points_x: 1
+      points_x: 2
+      points_x: 3
+      points_y: 4
+      points_y: 5
+      points_y: 6
+      points_z: 7
+      points_z: 8
+      points_z: 9
+    }
+    animation_speed: 123.456
+  }
+  trail {
+    map_id: 50
+    trail_data {
+      points_x: 1
+      points_x: 2
+      points_x: 3
+      points_y: 4
+      points_y: 5
+      points_y: 6
+      points_z: 7
+      points_z: 8
+      points_z: 9
+    }
+    animation_speed: -3.14
+  }
+  trail {
+    map_id: 50
+    trail_data {
+      points_x: 1
+      points_x: 2
+      points_x: 3
+      points_y: 4
+      points_y: 5
+      points_y: 6
+      points_z: 7
+      points_z: 8
+      points_z: 9
+    }
+    animation_speed: -123.456
+  }
+  trail {
+    map_id: 50
+    trail_data {
+      points_x: 1
+      points_x: 2
+      points_x: 3
+      points_y: 4
+      points_y: 5
+      points_y: 6
+      points_z: 7
+      points_z: 8
+      points_z: 9
+    }
+    animation_speed: -3.14
+  }
+  trail {
+    map_id: 50
+    trail_data {
+      points_x: 1
+      points_x: 2
+      points_x: 3
+      points_y: 4
+      points_y: 5
+      points_y: 6
+      points_z: 7
+      points_z: 8
+      points_z: 9
+    }
+    animation_speed: -123.456
+  }
+}

Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<OverlayData>
<MarkerCategory DisplayName="My Category" Name="mycategory">
</MarkerCategory>

<POIs>
<Trail AnimSpeed="0.000000" Type="mycategory"/>
<Trail Type="mycategory"/>
<Trail AnimSpeed="3.140000" Type="mycategory"/>
<Trail AnimSpeed="123.456001" Type="mycategory"/>
<Trail AnimSpeed="0.000000" Type="mycategory"/>
<Trail Type="mycategory"/>
<Trail AnimSpeed="3.140000" Type="mycategory"/>
<Trail AnimSpeed="123.456001" Type="mycategory"/>
<Trail AnimSpeed="-3.140000" Type="mycategory"/>
<Trail AnimSpeed="-123.456001" Type="mycategory"/>
<Trail AnimSpeed="-3.140000" Type="mycategory"/>
<Trail AnimSpeed="-123.456001" Type="mycategory"/>
</POIs>
</OverlayData>
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<OverlayData>
<MarkerCategory DisplayName="My Category" Name="mycategory">
</MarkerCategory>

<POIs>
<Trail AnimSpeed="0" Type="mycategory" />
<Trail AnimSpeed="1.0" Type="mycategory" />
<Trail AnimSpeed="3.14" Type="mycategory" />
<Trail AnimSpeed="123.456" Type="mycategory" />
<Trail AnimationSpeed="0" Type="mycategory" />
<Trail AnimationSpeed="1" Type="mycategory" />
<Trail AnimationSpeed="3.14" Type="mycategory" />
<Trail AnimationSpeed="123.456" Type="mycategory" />
AsherGlick marked this conversation as resolved.
Show resolved Hide resolved
<Trail AnimSpeed="-3.14" Type="mycategory" />
<Trail AnimSpeed="-123.456" Type="mycategory" />
<Trail AnimationSpeed="-3.14" Type="mycategory" />
<Trail AnimationSpeed="-123.456" Type="mycategory" />
</POIs>
</OverlayData>
8 changes: 7 additions & 1 deletion xml_converter/intigration_tests/testcases.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,18 @@ class Testcase:
expected_output_xml_path="./expected_outputs/xml_profession_filter",
expected_output_proto_path="./expected_outputs/proto_profession_filter",
),
Testcase(
name="animation_speed",
xml_input_paths=["./inputs/xml_animation_speed"],
expected_output_xml_path="./expected_outputs/xml_animation_speed",
expected_output_proto_path="./expected_outputs/proto_animation_speed"
),
Copy link
Owner

Choose a reason for hiding this comment

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

Where are the proto testcases?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As mentioned in the top comment, the proto will be changed by #151. I didn't want to add an incorrect proto

Copy link
Owner

Choose a reason for hiding this comment

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

Why not just change the proto here? Now seems like as good of a time as any to avoid it being forgotten.

Testcase(
name="cull_chirality",
xml_input_paths=["./inputs/xml_cull_chirality"],
expected_output_xml_path="./expected_outputs/xml_cull_chirality",
expected_output_proto_path="./expected_outputs/proto_cull_chirality",
).
),
Testcase(
name="specialization_filter",
xml_input_paths=["./inputs/xml_specialization_filter"],
Expand Down
21 changes: 21 additions & 0 deletions xml_converter/src/attribute/float.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,24 @@ void proto_to_float(float input, float* value, bool* is_set) {
void float_to_proto(float value, std::function<void(float&)> setter) {
setter(value);
}

////////////////////////////////////////////////////////////////////////////////
// replace_one_point_zero_with_zero
//
// Parses a float from the value of a rapidxml::xml_attribute and
// replaces default value of one with zero
////////////////////////////////////////////////////////////////////////////////
void default_value_one_xml_attribute_to_float(
rapidxml::xml_attribute<>* input,
std::vector<XMLError*>* errors,
XMLReaderState* state,
float* value,
bool* is_set) {
if (std::stof(get_attribute_value(input)) == 1.0) {
*value = 0;
}
else {
*value = std::stof(get_attribute_value(input));
*is_set = true;
}
}
7 changes: 7 additions & 0 deletions xml_converter/src/attribute/float.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,10 @@ std::string float_to_xml_attribute(const std::string& attribute_name, const floa
void proto_to_float(float input, float* value, bool* is_set);

void float_to_proto(float value, std::function<void(float&)> setter);

void default_value_one_xml_attribute_to_float(
rapidxml::xml_attribute<>* input,
std::vector<XMLError*>* errors,
XMLReaderState* state,
float* value,
bool* is_set);
4 changes: 2 additions & 2 deletions xml_converter/src/trail_gen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ bool Trail::init_xml_attribute(rapidxml::xml_attribute<>* attribute, vector<XMLE
xml_attribute_to_int(attribute, errors, state, &(this->achievement_id), &(this->achievement_id_is_set));
}
else if (attributename == "animspeed") {
xml_attribute_to_float(attribute, errors, state, &(this->animation_speed), &(this->animation_speed_is_set));
default_value_one_xml_attribute_to_float(attribute, errors, state, &(this->animation_speed), &(this->animation_speed_is_set));
}
else if (attributename == "animationspeed") {
xml_attribute_to_float(attribute, errors, state, &(this->animation_speed), &(this->animation_speed_is_set));
default_value_one_xml_attribute_to_float(attribute, errors, state, &(this->animation_speed), &(this->animation_speed_is_set));
}
else if (attributename == "type") {
xml_attribute_to_marker_category(attribute, errors, state, &(this->category), &(this->category_is_set));
Expand Down
Loading