Skip to content

Commit

Permalink
v2.1.2 update
Browse files Browse the repository at this point in the history
  • Loading branch information
selimanac committed Mar 30, 2024
1 parent 36524fa commit f5b3232
Show file tree
Hide file tree
Showing 9 changed files with 761 additions and 768 deletions.
31 changes: 31 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ Open your game.project file and in the dependencies field under project add:

## Release Notes

2.1.2

- Internal Update Frequency added. Default value is set from game.project file (display.frequency).
- It is now possible to set a new internal(independent from Defold game loop) update frequency by using `aabb.update_frequency()`.

2.1.1

- Table count added to query results.
Expand Down Expand Up @@ -494,6 +499,22 @@ Clear everything (AABBs,groups, gameobjects) and reset to initial state.
```


## aabb.update_frequency(`update_frequency`)

It is possible to set a independent update frequency for gameobject loop. Default value is set from game.project file(display.frequency).

**PARAMETERS**
* ```update_frequency``` (int) - Update Frequency.


**EXAMPLE**
```lua

aabb.update_frequency(5)

```



---

Expand All @@ -516,6 +537,16 @@ Clear everything (AABBs,groups, gameobjects) and reset to initial state.
**Publisher:** [8BitSkull](https://www.8bitskull.com/)
**Release Date:** 21 Oct, 2022
**Steam:** https://store.steampowered.com/app/2005210/Void_Scrappers/
**Switch:** 3 Mar, 2023

### Bore Blast

![DAABBCC](/assets/boreblast.jpg?raw=true)

**Developer:** [8BitSkull](https://www.8bitskull.com/)
**Publisher:** [8BitSkull](https://www.8bitskull.com/)
**Release Date:** 8 Mar, 2024
**Steam:** https://store.steampowered.com/app/2398170/BORE_BLASTERS/
**Switch:** TBA


Expand Down
Binary file added assets/boreblast.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
199 changes: 102 additions & 97 deletions daabbcc/include/DynamicTree.hpp
Original file line number Diff line number Diff line change
@@ -1,139 +1,144 @@
#ifndef DynamicTree_hpp
#define DynamicTree_hpp

#include <DynamicTree/b2DynamicTree.h>
#include "DynamicTree/b2DynamicTree.h"
#include <dmsdk/dlib/hashtable.h>
#include <dmsdk/dlib/log.h>
#include <dmsdk/sdk.h>

#define JC_SORT_IMPLEMENTATION
#include "jc/sort.h"

struct orderResultValues
{
int32 proxyID;
float32 distance;
struct orderResultValues {
int32 proxyID;
float32 distance;
};

class DynamicTree
{
class DynamicTree {
public:
DynamicTree();
~DynamicTree();
DynamicTree();
~DynamicTree();

// Add new group
int AddGroup();
int m_UpdateFrequency; // = dmConfigFile::GetInt(m_Config, "display.update_frequency", 0);
// Add new group
int AddGroup();

// Remove group
void RemoveGroup(int groupId);
// Remove group
void RemoveGroup(int groupId);

// Add new proxy(aabb)
int32 AddProxy(int groupId, float x, float y, int w, int h);
// Add new proxy(aabb)
int32 AddProxy(int groupId, float x, float y, int w, int h);

// Move Proxy
void MoveProxy(int groupId, int proxyID, float x, float y, int w, int h);
// Move Proxy
void MoveProxy(int groupId, int proxyID, float x, float y, int w, int h);

// Update GO W&H
void updateGameobjectSize(int groupID, int proxyID, int w, int h);
// Update GO W&H
void updateGameobjectSize(int groupID, int proxyID, int w, int h);

// Remove Proxy
void RemoveProxy(int groupID, int proxyID);
// Remove Proxy
void RemoveProxy(int groupID, int proxyID);

void RemoveProxyGameobject(int groupID, int proxyID);
void RemoveProxyGameobject(int groupID, int proxyID);

// b2DynamicTree query callback
bool QueryCallback(int32 proxyId, int groupId);
// b2DynamicTree query callback
bool QueryCallback(int32 proxyId, int groupId);

// b2DynamicTree raycast callback
float32 RayCastCallback(const b2RayCastInputAABB &input, int32 proxyId, int groupId);
// b2DynamicTree raycast callback
float32 RayCastCallback(const b2RayCastInputAABB &input, int32 proxyId, int groupId);

// RayCast to AABB
void RayCast(int groupId, float start_x, float start_y, float end_x, float end_y);
// RayCast to AABB
void RayCast(int groupId, float start_x, float start_y, float end_x, float end_y);

void RayCastSort(int groupId, float start_x, float start_y, float end_x, float end_y);
void RayCastSort(int groupId, float start_x, float start_y, float end_x, float end_y);

// Query with AABB
void QueryAABB(int groupId, float x, float y, int w, int h);
// Query with AABB
void QueryAABB(int groupId, float x, float y, int w, int h);

// Query with ID
void QueryID(int groupId, int proxyID); // std::vector<int32> QueryID(int groupId, int proxyID);
// Query with ID
void QueryID(int groupId,
int proxyID); // std::vector<int32> QueryID(int groupId, int proxyID);

// Query with ID - Distance Ordered
void QueryIDSort(int groupId, int proxyID);
// Query with ID - Distance Ordered
void QueryIDSort(int groupId, int proxyID);

void QueryAABBSort(int groupId, float x, float y, int w, int h);
void QueryAABBSort(int groupId, float x, float y, int w, int h);

void Run(bool toggle);
void Run(bool toggle);

// Query result
dmArray<int32> result;
void SetUpdateFrequency(int32_t updateFrequency);

// Raycast result
dmArray<int32> ray_result;
// Query result
dmArray<int32> result;

// Query order result
dmArray<orderResultValues> orderResult;
// Raycast result
dmArray<int32> ray_result;

// Assert
bool CheckGroup(int groupID);
// Query order result
dmArray<orderResultValues> orderResult;

bool isSorted = false;
// Assert
bool CheckGroup(int groupID);

void AddGameObject(uint32_t groupID, int32 proxyId, dmGameObject::HInstance instance, int32 w, int32 h);
bool isSorted;

void GameobjectUpdate();
void AddGameObject(uint32_t groupID, int32 proxyId, dmGameObject::HInstance instance, int32 w, int32 h);

void Clear();
void GameobjectUpdate();

void Clear();

private:
int groupCounter = 0;
int nodeProxyID = 0;
bool state = true;

struct Groups
{
b2DynamicTree *m_tree;
dmScript::LuaCallbackInfo *cbk;
};
dmHashTable<uint32_t, Groups> ht;

struct GameObjectContainer
{
uint32_t groupID;
int32 proxyId;
dmGameObject::HInstance instance;
int32 w;
int32 h;
};
dmArray<GameObjectContainer> m_GameObjectContainer;
uint32_t updateCounter = 0;
GameObjectContainer *updateContainer;

// Bound calculation
b2Vec2 Bound(int type, float x, float y, int w, int h);

// GetFatAABB -> GetAABB
b2AABB GetAABB(int groupId, int proxyID);

// Get AABB Position (Center)
b2Vec2 GetAABBPosition(int groupId, int proxyID);

// Query
void Query(int groupId, b2AABB aabb); // std::vector<int32> Query(int groupId, b2AABB aabb);

b2Vec2 nodeProxyCenter;
b2Vec2 targetProxyCenter;
dmVMath::Point3 goPosition;

orderResultValues tmpOrder;
dmArray<orderResultValues> tmpOrderResult;

static void IterateRemoveCallback(DynamicTree *context, const uint32_t *key, Groups *value);

void DestroyProxyID(int groupId, int proxyID);

// Reset class
void ResetTree();
int groupCounter;
int nodeProxyID;
bool state;

uint64_t m_PreviousFrameTime;
float m_AccumFrameTime;

struct Groups {
b2DynamicTree *m_tree;
dmScript::LuaCallbackInfo *cbk;
};
dmHashTable<uint32_t, Groups> ht;

struct GameObjectContainer {
uint32_t groupID;
int32 proxyId;
dmGameObject::HInstance instance;
int32 w;
int32 h;
};
dmArray<GameObjectContainer> m_GameObjectContainer;
uint32_t updateCounter;
GameObjectContainer *updateContainer;

// Bound calculation
b2Vec2 Bound(int type, float x, float y, int w, int h);

// GetFatAABB -> GetAABB
b2AABB GetAABB(int groupId, int proxyID);

// Get AABB Position (Center)
b2Vec2 GetAABBPosition(int groupId, int proxyID);

// Query
// std::vector<int32> Query(int groupId, b2AABB aabb);
void Query(int groupId, b2AABB aabb);

b2Vec2 nodeProxyCenter;
b2Vec2 targetProxyCenter;
dmVMath::Point3 goPosition;

orderResultValues tmpOrder;
dmArray<orderResultValues> tmpOrderResult;

static void IterateRemoveCallback(DynamicTree *context, const uint32_t *key, Groups *value);
void CalcTimeStep(float &step_dt, uint32_t &num_steps);

void DestroyProxyID(int groupId, int proxyID);

// Reset class
void ResetTree();
};

#endif /* DynamicTree_hpp */
Loading

0 comments on commit f5b3232

Please sign in to comment.