Skip to content

Commit

Permalink
Updated drawing and various others
Browse files Browse the repository at this point in the history
  • Loading branch information
joelbeedle committed Feb 23, 2024
1 parent 9046799 commit 447a0c6
Show file tree
Hide file tree
Showing 7 changed files with 975 additions and 776 deletions.
2 changes: 2 additions & 0 deletions include/Drone.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,6 @@ class Drone {
}

std::vector<Tree *> getFoundTrees() { return foundTrees; }

void clearLists();
};
5 changes: 4 additions & 1 deletion include/Tree.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ class Tree {
bool diseased;
bool mapped;
float radius;
int treeID;

public:
Tree(b2World *world, const b2Vec2 &position, bool diseased,
Tree(b2World *world, int treeID, const b2Vec2 &position, bool diseased,
bool mapped = false, float radius = 1.0f);
~Tree();

Expand All @@ -20,5 +21,7 @@ class Tree {
bool isMapped() { return mapped; }
void setMapped(bool isMapped) { mapped = isMapped; }
b2Body *getBody() { return body; }
void setID(int newID) { treeID = newID; }
int getID() { return treeID; }
void render();
};
12 changes: 9 additions & 3 deletions src/Drone.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,14 +97,20 @@ void Drone::updateSensorRange() {
viewSensor = body->CreateFixture(&sFixtureDef);
}

void Drone::clearLists() {
this->foundDiseasedTrees.clear();
this->foundDiseasedTreePositions.clear();
this->foundTrees.clear();
}

void Drone::update(std::vector<Drone *> &drones) {
if (behaviour) {
behaviour->execute(drones, this);
}
// Clear found trees for this cycle?
this->foundDiseasedTrees.clear();
this->foundDiseasedTreePositions.clear();
this->foundTrees.clear();
// this->foundDiseasedTrees.clear();
// this->foundDiseasedTreePositions.clear();
// this->foundTrees.clear();

b2Vec2 position = body->GetPosition();

Expand Down
6 changes: 3 additions & 3 deletions src/Tree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

#include "ObjectTypes.h"

Tree::Tree(b2World *world, const b2Vec2 &position, bool diseased, bool mapped,
float radius)
: diseased(diseased), mapped(mapped), radius(radius) {
Tree::Tree(b2World *world, int treeID, const b2Vec2 &position, bool diseased,
bool mapped, float radius)
: treeID(treeID), diseased(diseased), mapped(mapped), radius(radius) {
// Create Box2D body
b2BodyDef bodyDef;
bodyDef.type = b2_staticBody;
Expand Down
Loading

0 comments on commit 447a0c6

Please sign in to comment.