Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

Simple QuadTree written in C++ with SFML demo

NotificationsYou must be signed in to change notification settings

m-byte918/QuadTree-Cpp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Simple QuadTree written in C++ with SFML demo

SFML Demo

Constructing a quadtree

QuadTree *quadTree =new QuadTree({ x, y, width, height },8,4);

Inserting objects

// Inserts an object into the quadtreeint data =5;Collidable obj = Collidable({ x, y, width, height }, data);quadTree->insert(&obj);

Removing objects

// Removes an object from the quadtreequadTree->remove(&obj);

Updating objects

// Updates an object within the quadtree// Useful for objects that moveobj.bound.x =123.456;obj.bound.y =654.321;quadTree->update(&obj);

Searching for objects within boundary

// Getting objects within a particular boundaryRect box = { x, y, width, height };std::vector<Collidable*> foundObjects = quadTree->getObjectsInBound(box);

Getting objects & children count

std::cout << quadTree->totalChildren() << "\n";std::cout << quadTree->totalObjects() << "\n";

Clearing a quadtree

quadTree->clear();

Getting data from a Collidable

int stuff =123;Collidable obj = Collidable({0,0,10,20}, stuff);std::cout << std::any_cast<int>(obj.data) <<'\n';

About

Simple QuadTree written in C++ with SFML demo

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages


[8]ページ先頭

©2009-2025 Movatter.jp