From ea9a0018087f9262d074e5cfb88112996d41423f Mon Sep 17 00:00:00 2001 From: cutealien Date: Mon, 29 Jan 2024 16:05:31 +0000 Subject: [PATCH] Add aabbox3d::getSideCenters Returns centers of the side faces. Just another tool function to fatten up Irrlicht git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6591 dfc29bdd-3216-0410-991c-e03cc46cb475 --- include/aabbox3d.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/include/aabbox3d.h b/include/aabbox3d.h index 7d143d54..3933403e 100644 --- a/include/aabbox3d.h +++ b/include/aabbox3d.h @@ -175,6 +175,22 @@ class aabbox3d corners[7].set(middle.X - diag.X, middle.Y - diag.Y, middle.Z - diag.Z); } + //! Stores all 6 centers of the box side faces into an array + /** \param sideCenters: Pointer to array of 6 corners. */ + void getSideCenters(vector3d *corners) const + { + const core::vector3d middle = getCenter(); + const core::vector3d diag = middle - MaxEdge; + + corners[0].set(middle.X + diag.X, middle.Y, middle.Z); + corners[1].set(middle.X - diag.X, middle.Y, middle.Z); + corners[2].set(middle.X, middle.Y + diag.Y, middle.Z); + corners[3].set(middle.X, middle.Y - diag.Y, middle.Z); + corners[4].set(middle.X, middle.Y, middle.Z + diag.Z); + corners[5].set(middle.X, middle.Y, middle.Z - diag.Z); + } + + //! Repairs the box. /** Necessary if for example MinEdge and MaxEdge are swapped. */ void repair()