客户端问题修改
This commit is contained in:
@@ -22,4 +22,8 @@ if(BUILD_TESTING)
|
||||
add_executable(libgr2_loader_errors_test tests/loader_errors.cpp)
|
||||
target_link_libraries(libgr2_loader_errors_test PRIVATE xrender::libgr2)
|
||||
add_test(NAME libgr2.loader_errors COMMAND libgr2_loader_errors_test)
|
||||
|
||||
add_executable(libgr2_animation_test tests/animation.cpp)
|
||||
target_link_libraries(libgr2_animation_test PRIVATE xrender::libgr2)
|
||||
add_test(NAME libgr2.animation COMMAND libgr2_animation_test)
|
||||
endif()
|
||||
|
||||
@@ -179,7 +179,11 @@ void Curve::eval(float t, float* out) const {
|
||||
const int first = (degree == 1) ? (i - 1) : (i - 2);
|
||||
|
||||
// 拷本 span 的控制点(越界按端点 clamp),四元数做半球连续化
|
||||
float cp[3 * 4]; // 最多 3 点 × dim4
|
||||
// Metin2 的 ScaleShearCurve 是 9 维;旧的 3*4 缓冲区会在这里发生
|
||||
// 栈溢出(degree=2 时写入 27 个 float),随后被 __stack_chk_fail 终止。
|
||||
// 目前支持的曲线维度为 position=3、orientation=4、scale/shear=9。
|
||||
if (dim > 9) return;
|
||||
float cp[3 * 9];
|
||||
for (int s = 0; s < span; ++s) {
|
||||
int ci = first + s;
|
||||
ci = ci < 0 ? 0 : (ci >= (int)n ? (int)n - 1 : ci);
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
#include <gr2/types.h>
|
||||
|
||||
#include <cmath>
|
||||
#include <cstdio>
|
||||
|
||||
int main() {
|
||||
// ScaleShearCurve uses 9 values per control point. A quadratic span reads
|
||||
// three control points, so this is the regression case for the former 3*4
|
||||
// stack buffer in Curve::eval().
|
||||
gr2::Curve curve;
|
||||
curve.degree = 2;
|
||||
curve.dim = 9;
|
||||
curve.knots = {0.0f, 1.0f, 2.0f};
|
||||
curve.controls.resize(27);
|
||||
for (size_t i = 0; i < curve.controls.size(); ++i) {
|
||||
curve.controls[i] = 1.0f + static_cast<float>(i) * 0.01f;
|
||||
}
|
||||
|
||||
float out[9] = {};
|
||||
curve.eval(0.5f, out);
|
||||
for (float value : out) {
|
||||
if (!std::isfinite(value)) {
|
||||
std::fprintf(stderr, "non-finite 9D curve output\n");
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user