-
Автор темы
- #1
Код:
auto get_bbox = [ & ]( ) -> rect_t {
vec3_t origin2;
_driver.read<vec3_t>( node + offsets::game_scene.abs_origin, origin2 );
vec2_t flb, brt, blb, frt, frb, brb, blt, flt = { };
float left, top, right, bottom = 0.f;
uintptr_t collideable;
if ( !_driver.read( ent + 0x320, collideable ) ) {
print_error( "[1]" )
}
vec3_t min_o, max_o;
_driver.read( collideable + 0x40, min_o );
_driver.read( collideable + 0x4C, max_o );
vec3_t min = min_o + origin2;
vec3_t max = max_o + origin2;
std::array<vec3_t, 8> points = {
vec3_t( min.x, min.y, min.z ),
vec3_t( min.x, min.y, max.z ),
vec3_t( min.x, max.y, min.z ),
vec3_t( min.x, max.y, max.z ),
vec3_t( max.x, min.y, min.z ),
vec3_t( max.x, min.y, max.z ),
vec3_t( max.x, max.y, min.z ),
vec3_t( max.x, max.y, max.z ) };
if ( !_address->view.world_to_screen( points[ 3 ], flb )
|| !_address->view.world_to_screen( points[ 5 ], brt )
|| !_address->view.world_to_screen( points[ 0 ], blb )
|| !_address->view.world_to_screen( points[ 4 ], frt )
|| !_address->view.world_to_screen( points[ 2 ], frb )
|| !_address->view.world_to_screen( points[ 1 ], brb )
|| !_address->view.world_to_screen( points[ 6 ], blt )
|| !_address->view.world_to_screen( points[ 7 ], flt ) ) {
print_error( "[0]" )
}
std::array<vec2_t, 8> arr = { flb, brt, blb, frt, frb, brb, blt, flt };
left = flb.x;
top = flb.y;
right = flb.x;
bottom = flb.y;
for ( std::int32_t i = 1; i < 8; i++ ) {
if ( left > arr[ i ].x ) {
left = arr[i].x;
}
if ( bottom < arr[ i ].y ) {
bottom = arr[ i ].y;
}
if ( right < arr[ i ].x ) {
right = arr[i].x;
}
if ( top > arr[ i ].y ) {
top = arr[i].y;
}
}
return rect_t{
(int)left
(int)top
(int)( right - left ),
(int)( bottom - top )
};
};