-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
A maya command plug-in that is used to manipulate an animation curve. This also adds C++ bindings via CXX. GitHub issue #268
- Loading branch information
1 parent
78fbc47
commit 9d5ba41
Showing
15 changed files
with
642 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
lib/cppbind/mmscenegraph/include/mmscenegraph/curve_detect_pops.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* | ||
* Copyright (C) 2024 David Cattermole. | ||
* | ||
* This file is part of mmSolver. | ||
* | ||
* mmSolver is free software: you can redistribute it and/or modify it | ||
* under the terms of the GNU Lesser General Public License as | ||
* published by the Free Software Foundation, either version 3 of the | ||
* License, or (at your option) any later version. | ||
* | ||
* mmSolver is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with mmSolver. If not, see <https://www.gnu.org/licenses/>. | ||
* ==================================================================== | ||
* | ||
*/ | ||
|
||
#ifndef MM_SOLVER_MM_SCENE_GRAPH_CURVE_DETECT_POPS_H | ||
#define MM_SOLVER_MM_SCENE_GRAPH_CURVE_DETECT_POPS_H | ||
|
||
#include "_cxx.h" | ||
#include "_cxxbridge.h" | ||
#include "_symbol_export.h" | ||
#include "_types.h" | ||
|
||
namespace mmscenegraph { | ||
|
||
MMSCENEGRAPH_API_EXPORT | ||
bool detect_curve_pops(rust::Slice<const Real> &x_values, | ||
rust::Slice<const Real> &y_values, const Real threshold, | ||
rust::Vec<Real> &out_x_values, | ||
rust::Vec<Real> &out_y_values) noexcept; | ||
|
||
MMSCENEGRAPH_API_EXPORT | ||
bool filter_curve_pops(rust::Slice<const Real> &x_values, | ||
rust::Slice<const Real> &y_values, const Real threshold, | ||
rust::Vec<Real> &out_x_values, | ||
rust::Vec<Real> &out_y_values) noexcept; | ||
|
||
} // namespace mmscenegraph | ||
|
||
#endif // MM_SOLVER_MM_SCENE_GRAPH_CURVE_DETECT_POPS_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* | ||
* Copyright (C) 2024 David Cattermole. | ||
* | ||
* This file is part of mmSolver. | ||
* | ||
* mmSolver is free software: you can redistribute it and/or modify it | ||
* under the terms of the GNU Lesser General Public License as | ||
* published by the Free Software Foundation, either version 3 of the | ||
* License, or (at your option) any later version. | ||
* | ||
* mmSolver is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with mmSolver. If not, see <https://www.gnu.org/licenses/>. | ||
* ==================================================================== | ||
* | ||
*/ | ||
|
||
#include <mmscenegraph/_cxx.h> | ||
#include <mmscenegraph/_cxxbridge.h> | ||
#include <mmscenegraph/curve_detect_pops.h> | ||
|
||
namespace mmscenegraph { | ||
|
||
MMSCENEGRAPH_API_EXPORT | ||
bool detect_curve_pops(rust::Slice<const Real> &x_values, | ||
rust::Slice<const Real> &y_values, const Real threshold, | ||
rust::Vec<Real> &out_x_values, | ||
rust::Vec<Real> &out_y_values) noexcept { | ||
return shim_detect_curve_pops(x_values, y_values, threshold, out_x_values, | ||
out_y_values); | ||
} | ||
|
||
MMSCENEGRAPH_API_EXPORT | ||
bool filter_curve_pops(rust::Slice<const Real> &x_values, | ||
rust::Slice<const Real> &y_values, const Real threshold, | ||
rust::Vec<Real> &out_x_values, | ||
rust::Vec<Real> &out_y_values) noexcept { | ||
return shim_filter_curve_pops(x_values, y_values, threshold, out_x_values, | ||
out_y_values); | ||
} | ||
|
||
} // namespace mmscenegraph |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
// | ||
// Copyright (C) 2024 David Cattermole. | ||
// | ||
// This file is part of mmSolver. | ||
// | ||
// mmSolver is free software: you can redistribute it and/or modify it | ||
// under the terms of the GNU Lesser General Public License as | ||
// published by the Free Software Foundation, either version 3 of the | ||
// License, or (at your option) any later version. | ||
// | ||
// mmSolver is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU Lesser General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU Lesser General Public License | ||
// along with mmSolver. If not, see <https://www.gnu.org/licenses/>. | ||
// ==================================================================== | ||
// | ||
|
||
use mmscenegraph_rust::constant::Real as CoreReal; | ||
use mmscenegraph_rust::curve::detect::pops::detect_curve_pops as core_detect_curve_pops; | ||
use mmscenegraph_rust::curve::detect::pops::filter_curve_pops as core_filter_curve_pops; | ||
|
||
pub fn shim_detect_curve_pops( | ||
// xy_values: &[(CoreReal, CoreReal)], | ||
x_values: &[CoreReal], | ||
y_values: &[CoreReal], | ||
threshold: CoreReal, | ||
out_x_values: &mut Vec<CoreReal>, | ||
out_y_values: &mut Vec<CoreReal>, | ||
) -> bool { | ||
let result = core_detect_curve_pops(&x_values, &y_values, threshold); | ||
match result { | ||
Ok(values) => { | ||
let new_x_capacity = | ||
values.len().saturating_sub(out_x_values.capacity()); | ||
let new_y_capacity = | ||
values.len().saturating_sub(out_y_values.capacity()); | ||
out_x_values.reserve_exact(new_x_capacity); | ||
out_y_values.reserve_exact(new_y_capacity); | ||
out_x_values.clear(); | ||
out_y_values.clear(); | ||
|
||
for value in values.iter() { | ||
let x = value.0; | ||
let y = value.1; | ||
out_x_values.push(x); | ||
out_y_values.push(y); | ||
} | ||
|
||
true | ||
} | ||
Err(_) => false, | ||
} | ||
} | ||
|
||
pub fn shim_filter_curve_pops( | ||
// xy_values: &[(CoreReal, CoreReal)], | ||
x_values: &[CoreReal], | ||
y_values: &[CoreReal], | ||
threshold: CoreReal, | ||
out_x_values: &mut Vec<CoreReal>, | ||
out_y_values: &mut Vec<CoreReal>, | ||
) -> bool { | ||
let result = core_filter_curve_pops(&x_values, &y_values, threshold); | ||
match result { | ||
Ok(values) => { | ||
let new_x_capacity = | ||
values.len().saturating_sub(out_x_values.capacity()); | ||
let new_y_capacity = | ||
values.len().saturating_sub(out_y_values.capacity()); | ||
out_x_values.reserve_exact(new_x_capacity); | ||
out_y_values.reserve_exact(new_y_capacity); | ||
out_x_values.clear(); | ||
out_y_values.clear(); | ||
|
||
for value in values.iter() { | ||
let x = value.0; | ||
let y = value.1; | ||
out_x_values.push(x); | ||
out_y_values.push(y); | ||
} | ||
|
||
true | ||
} | ||
Err(_) => false, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.