Threads and tasks

This commit is contained in:
2026-01-29 15:28:50 +03:00
parent 4cf0ea5321
commit da4c1fee0e
21 changed files with 1464 additions and 558 deletions

View File

@@ -18,29 +18,45 @@ struct ActionNodeList {
float radius;
nlohmann::json props;
};
std::vector<ActionNode> nodes, dynamicNodes;
std::shared_ptr<indexObject> indexObj;
std::vector<size_t> points;
std::vector<float> distances;
int selected;
struct UIData {
std::shared_ptr<std::mutex> mutex;
int selected;
std::vector<size_t> points;
std::vector<float> distances;
UIData()
: mutex(std::make_shared<std::mutex>())
, selected(-1)
{
}
};
private:
bool dirty;
bool busy;
std::shared_ptr<indexObject> indexObj;
struct UIData uidata;
bool _query(const Ogre::Vector3 &position, std::vector<size_t> &points,
std::vector<float> &distances);
public:
std::shared_ptr<std::mutex> nodeMutex;
std::vector<ActionNode> nodes, dynamicNodes;
void updateDynamicNodes();
void build();
bool query(const Ogre::Vector3 &position, std::vector<size_t> &points, std::vector<float> &distances);
int addNode(struct ActionNodeList::ActionNode &node)
{
int index = nodes.size();
nodes.push_back(node);
dirty = true;
return index;
}
void removeNode(int index)
{
nodes.erase(nodes.begin() + index);
}
};
struct NPCActionNodes {
std::vector<ActionNodeList::ActionNode> anodes;
bool query_ai(const Ogre::Vector3 &position, float distance,
std::vector<size_t> &points,
std::vector<float> &distances);
int addNode(struct ActionNodeList::ActionNode &node);
void removeNode(int index);
const UIData &getUIData();
void setUISelected(int selected);
void setUIPoints(const std::vector<size_t> &points,
const std::vector<float> &distances);
void UIquery(const Ogre::Vector3 &position);
void setDirty(); // node was added or removed
void setReady();
void setBusy();
bool isBusy();
};
struct PlayerActionModule {
struct ActionWordHandler {