Skip to content

Commit

Permalink
Went a different direction implementing the modeling strength so remo…
Browse files Browse the repository at this point in the history
…ving the extra field

PiperOrigin-RevId: 652459257
  • Loading branch information
Ink Open Source authored and copybara-github committed Jul 15, 2024
1 parent c344295 commit 1308153
Show file tree
Hide file tree
Showing 11 changed files with 1,402 additions and 2,616 deletions.
5 changes: 2 additions & 3 deletions ink_stroke_modeler/internal/internal_types.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,8 @@ std::string ToFormattedString(const TipState &tip_state) {

std::string ToFormattedString(const StylusState &stylus_state) {
return absl::StrFormat(
"<StylusState: pressure: %v, tilt: %v, orientation: %v>, position: %v",
stylus_state.pressure, stylus_state.tilt, stylus_state.orientation,
stylus_state.position);
"<StylusState: pressure: %v, tilt: %v, orientation: %v>",
stylus_state.pressure, stylus_state.tilt, stylus_state.orientation);
}

} // namespace stroke_model
Expand Down
3 changes: 1 addition & 2 deletions ink_stroke_modeler/internal/internal_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ struct StylusState {
float pressure = -1;
float tilt = -1;
float orientation = -1;
Vec2 position{0};
};

bool operator==(const StylusState& lhs, const StylusState& rhs);
Expand All @@ -63,7 +62,7 @@ void AbslStringify(Sink& sink, const StylusState& stylus_state) {

inline bool operator==(const StylusState& lhs, const StylusState& rhs) {
return lhs.pressure == rhs.pressure && lhs.tilt == rhs.tilt &&
lhs.orientation == rhs.orientation && lhs.position == rhs.position;
lhs.orientation == rhs.orientation;
}

} // namespace stroke_model
Expand Down
5 changes: 2 additions & 3 deletions ink_stroke_modeler/internal/internal_types_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,8 @@ TEST(InternalTypesTest, StylusStateEquals) {
}

TEST(InternalTypesTest, StylusStateString) {
EXPECT_EQ(absl::StrFormat("%v", StylusState{0.1, 0.2, 0.3, {1, 2}}),
"<StylusState: pressure: 0.1, tilt: 0.2, orientation: 0.3>, "
"position: (1, 2)");
EXPECT_EQ(absl::StrFormat("%v", StylusState{0.1, 0.2, 0.3}),
"<StylusState: pressure: 0.1, tilt: 0.2, orientation: 0.3>");
}

} // namespace
Expand Down
8 changes: 3 additions & 5 deletions ink_stroke_modeler/internal/stylus_state_modeler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ void StylusStateModeler::Reset(const StylusStateModelerParams &params) {

StylusState StylusStateModeler::Query(Vec2 position) const {
if (state_.positions_and_stylus_states.empty())
return {.pressure = -1, .tilt = -1, .orientation = -1, .position = {0, 0}};
return {.pressure = -1, .tilt = -1, .orientation = -1};

int closest_segment_index = -1;
float min_distance = std::numeric_limits<float>::infinity();
Expand All @@ -89,8 +89,7 @@ StylusState StylusStateModeler::Query(Vec2 position) const {
return {.pressure = state_.received_unknown_pressure ? -1 : state.pressure,
.tilt = state_.received_unknown_tilt ? -1 : state.tilt,
.orientation =
state_.received_unknown_orientation ? -1 : state.orientation,
.position = state.position};
state_.received_unknown_orientation ? -1 : state.orientation};
}

auto from_state =
Expand All @@ -108,8 +107,7 @@ StylusState StylusStateModeler::Query(Vec2 position) const {
.orientation = state_.received_unknown_orientation
? -1
: InterpAngle(from_state.orientation,
to_state.orientation, interp_value),
.position = Interp(from_state.position, to_state.position, interp_value)};
to_state.orientation, interp_value)};
}

void StylusStateModeler::Save() {
Expand Down
Loading

0 comments on commit 1308153

Please sign in to comment.