diff --git a/Perception.cpp b/Perception.cpp index 578eeac..be8a886 100644 --- a/Perception.cpp +++ b/Perception.cpp @@ -277,6 +277,25 @@ InterestingThing **Perception::GetTrackedObjects() { return this->trackedObjects; } +unsigned char Perception::GetThingsOfType(unsigned char objectType, + InterestingThing *buffer[], + unsigned char bufferSize) { + unsigned char thingCount = 0; + for (unsigned char objIx = 0; objIx < maxObjectCount; objIx++) { + InterestingThing *thing = this->trackedObjects[objIx]; + if (thing == nullptr) + continue; + + if (thing->type == objectType) { + buffer[thingCount] = thing; + thingCount++; + if (thingCount >= bufferSize) + return bufferSize; + } + } + return thingCount; +} + InterestingThing *Perception::GetMostInterestingThing() { InterestingThing *closestObject = nullptr; float closestDistance = INFINITY; diff --git a/Perception.h b/Perception.h index 5cad413..730624f 100644 --- a/Perception.h +++ b/Perception.h @@ -103,6 +103,10 @@ public: /// currently being tracked. InterestingThing **GetTrackedObjects(); + unsigned char GetThingsOfType(unsigned char objectType, + InterestingThing *buffer[], + unsigned char bufferSize); + InterestingThing *GetMostInterestingThing(); // mainly used for confidence update