diff --git a/extension.cpp b/extension.cpp index 68b29fa..88158c6 100644 --- a/extension.cpp +++ b/extension.cpp @@ -114,6 +114,7 @@ class KDTreeContainer public: PointCloud cloud; my_kd_tree_t *index; + int startidx; }; class ClosestPosTypeHandler : public IHandleTypeDispatch @@ -254,6 +255,7 @@ static cell_t sm_CreateClosestPos(IPluginContext *pContext, const cell_t *params } KDTreeContainer *container = new KDTreeContainer(); + container->startidx = startidx; container->cloud.pts.resize(count); for (size_t i = 0; i < count; i++) @@ -296,7 +298,7 @@ static cell_t sm_Find(IPluginContext *pContext, const cell_t *params) container->index->knnSearch(&query_pt[0], num_results, &ret_index, &out_dist_sqr); - return ret_index; + return container->startidx + ret_index; } extern const sp_nativeinfo_t ClosestPosNatives[] = diff --git a/smsdk_config.h b/smsdk_config.h index 6e9f2be..c25ad42 100644 --- a/smsdk_config.h +++ b/smsdk_config.h @@ -40,7 +40,7 @@ /* Basic information exposed publicly */ #define SMEXT_CONF_NAME "ClosestPos" #define SMEXT_CONF_DESCRIPTION "Provides a type that can be used to quickly find the closest point to the input position." -#define SMEXT_CONF_VERSION "1.1.0.0" +#define SMEXT_CONF_VERSION "1.1.1.0" #define SMEXT_CONF_AUTHOR "rtldg" #define SMEXT_CONF_URL "https://github.com/rtldg/sm_closestpos" #define SMEXT_CONF_LOGTAG "CLOSESTPOS"