Skip to content

Commit

Permalink
make sure the returned index adds startidx
Browse files Browse the repository at this point in the history
  • Loading branch information
rtldg committed Nov 3, 2021
1 parent 128f9ea commit b0a9b88
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion extension.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ class KDTreeContainer
public:
PointCloud<float> cloud;
my_kd_tree_t *index;
int startidx;
};

class ClosestPosTypeHandler : public IHandleTypeDispatch
Expand Down Expand Up @@ -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++)
Expand Down Expand Up @@ -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[] =
Expand Down
2 changes: 1 addition & 1 deletion smsdk_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit b0a9b88

Please sign in to comment.