Reader small image

You're reading from  Game Physics Cookbook

Product typeBook
Published inMar 2017
Reading LevelIntermediate
PublisherPackt
ISBN-139781787123663
Edition1st Edition
Languages
Tools
Concepts
Right arrow
Author (1)
Gabor Szauer
Gabor Szauer
author image
Gabor Szauer

Gabor Szauer has been making games since 2010. He graduated from Full Sail University in 2010 with a bachelor's degree in game development. Gabor maintains an active Twitter presence, and maintains a programming-oriented game development blog. Gabor's previously published books are Game Physics Programming Cookbook and Lua Quick Start Guide, both published by Packt.
Read more about Gabor Szauer

Right arrow

Octree contents


Once we have built an octree, we must manage models that might occupy the same space as the tree. There are three operations that will help us manage models within the tree. We want to know when a model is added to the tree or removed from the tree. We also want to know when a model moves, as it may occupy different leaf nodes at its new position.

Getting ready

In this section, we are going to implement three support functions for the octree. We are going to create an Insert function for when something is added to the tree. We are going to create a Remove function for when something is removed from the tree. And finally, an Update function for when something within the tree moves. The update function will simply remove the model from the tree and reinsert it.

How to do it…

Follow these steps to add objects to the octree or to remove objects from the octree:

  1. Declare the Insert, Remove, and Update functions in Scene.h:

    void Insert(OctreeNode* node, Model* model);
    void Remove(OctreeNode...
lock icon
The rest of the page is locked
Previous PageNext Page
You have been reading a chapter from
Game Physics Cookbook
Published in: Mar 2017Publisher: PacktISBN-13: 9781787123663

Author (1)

author image
Gabor Szauer

Gabor Szauer has been making games since 2010. He graduated from Full Sail University in 2010 with a bachelor's degree in game development. Gabor maintains an active Twitter presence, and maintains a programming-oriented game development blog. Gabor's previously published books are Game Physics Programming Cookbook and Lua Quick Start Guide, both published by Packt.
Read more about Gabor Szauer