From 412a80b5c2b8c8704a03cb374da21eadee8af531 Mon Sep 17 00:00:00 2001 From: "madmaxoft@gmail.com" Date: Sun, 31 Mar 2013 18:22:55 +0000 Subject: [PATCH] cCuboid: Added the IsCompletelyInside() function git-svn-id: http://mc-server.googlecode.com/svn/trunk@1339 0a769ca7-a7f5-676a-18bf-c427514a06d6 --- source/Bindings.cpp | 37 ++++++++++++++++++++++++++++++++++++- source/Bindings.h | 2 +- source/Cuboid.cpp | 16 ++++++++++++++++ source/Cuboid.h | 3 +++ 4 files changed, 56 insertions(+), 2 deletions(-) diff --git a/source/Bindings.cpp b/source/Bindings.cpp index 569b9d305..7512bba25 100644 --- a/source/Bindings.cpp +++ b/source/Bindings.cpp @@ -1,6 +1,6 @@ /* ** Lua binding: AllToLua -** Generated automatically by tolua++-1.0.92 on 03/31/13 18:21:23. +** Generated automatically by tolua++-1.0.92 on 03/31/13 20:21:16. */ #ifndef __cplusplus @@ -17838,6 +17838,40 @@ tolua_lerror: } #endif //#ifndef TOLUA_DISABLE +/* method: IsCompletelyInside of class cCuboid */ +#ifndef TOLUA_DISABLE_tolua_AllToLua_cCuboid_IsCompletelyInside00 +static int tolua_AllToLua_cCuboid_IsCompletelyInside00(lua_State* tolua_S) +{ +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"const cCuboid",0,&tolua_err) || + (tolua_isvaluenil(tolua_S,2,&tolua_err) || !tolua_isusertype(tolua_S,2,"const cCuboid",0,&tolua_err)) || + !tolua_isnoobj(tolua_S,3,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + const cCuboid* self = (const cCuboid*) tolua_tousertype(tolua_S,1,0); + const cCuboid* a_Outer = ((const cCuboid*) tolua_tousertype(tolua_S,2,0)); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'IsCompletelyInside'", NULL); +#endif + { + bool tolua_ret = (bool) self->IsCompletelyInside(*a_Outer); + tolua_pushboolean(tolua_S,(bool)tolua_ret); + } + } + return 1; +#ifndef TOLUA_RELEASE + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'IsCompletelyInside'.",&tolua_err); + return 0; +#endif +} +#endif //#ifndef TOLUA_DISABLE + /* method: Move of class cCuboid */ #ifndef TOLUA_DISABLE_tolua_AllToLua_cCuboid_Move00 static int tolua_AllToLua_cCuboid_Move00(lua_State* tolua_S) @@ -23918,6 +23952,7 @@ TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S) tolua_function(tolua_S,"IsInside",tolua_AllToLua_cCuboid_IsInside00); tolua_function(tolua_S,"IsInside",tolua_AllToLua_cCuboid_IsInside01); tolua_function(tolua_S,"IsInside",tolua_AllToLua_cCuboid_IsInside02); + tolua_function(tolua_S,"IsCompletelyInside",tolua_AllToLua_cCuboid_IsCompletelyInside00); tolua_function(tolua_S,"Move",tolua_AllToLua_cCuboid_Move00); tolua_function(tolua_S,"IsSorted",tolua_AllToLua_cCuboid_IsSorted00); tolua_endmodule(tolua_S); diff --git a/source/Bindings.h b/source/Bindings.h index c3a9cd304..60b6ade5e 100644 --- a/source/Bindings.h +++ b/source/Bindings.h @@ -1,6 +1,6 @@ /* ** Lua binding: AllToLua -** Generated automatically by tolua++-1.0.92 on 03/31/13 18:21:24. +** Generated automatically by tolua++-1.0.92 on 03/31/13 20:21:17. */ /* Exported function */ diff --git a/source/Cuboid.cpp b/source/Cuboid.cpp index b7de25b26..ea6f7c453 100644 --- a/source/Cuboid.cpp +++ b/source/Cuboid.cpp @@ -72,6 +72,22 @@ bool cCuboid::DoesIntersect(const cCuboid & a_Other) const +bool cCuboid::IsCompletelyInside(const cCuboid & a_Outer) const +{ + return ( + (p1.x >= a_Outer.p1.x) && + (p2.x <= a_Outer.p2.x) && + (p1.y >= a_Outer.p1.y) && + (p2.y <= a_Outer.p2.y) && + (p1.z >= a_Outer.p1.z) && + (p2.z <= a_Outer.p2.z) + ); +} + + + + + void cCuboid::Move(int a_OfsX, int a_OfsY, int a_OfsZ) { p1.x += a_OfsX; diff --git a/source/Cuboid.h b/source/Cuboid.h index 577bfa401..44db7b98e 100644 --- a/source/Cuboid.h +++ b/source/Cuboid.h @@ -59,6 +59,9 @@ public: ); } + /// Returns true if this cuboid is completely inside the specifie cuboid (in all 6 coords) + bool IsCompletelyInside(const cCuboid & a_Outer) const; + /// Moves the cuboid by the specified offsets in each direction void Move(int a_OfsX, int a_OfsY, int a_OfsZ);