Dateien nach "/" hochladen
This commit is contained in:
@@ -0,0 +1,66 @@
|
||||
#include "inc/include.h"
|
||||
|
||||
bool math::setup_render_points(Context* ctx, const matrix3x4 &coord_frame, const Vector3D &mins, const Vector3D &maxs, render_points_t &out)
|
||||
{
|
||||
const int num_transformations = 8;
|
||||
|
||||
Vector3D transformed[num_transformations];
|
||||
Vector3D points[num_transformations] = {
|
||||
{mins.x, mins.y, mins.z},
|
||||
{mins.x, maxs.y, mins.z},
|
||||
{maxs.x, maxs.y, mins.z},
|
||||
{maxs.x, mins.y, mins.z},
|
||||
{mins.x, maxs.y, maxs.z},
|
||||
{mins.x, mins.y, maxs.z},
|
||||
{maxs.x, mins.y, maxs.z}};
|
||||
|
||||
for (int i = 0; i < num_transformations; i++)
|
||||
{
|
||||
vector_transform(points[i], coord_frame, transformed[i]);
|
||||
}
|
||||
|
||||
Vector3D flb{}, brt{}, blb{}, frt{}, frb{}, brb{}, blt{}, flt{};
|
||||
if (!render::w2s(ctx, transformed[3], &flb) || !render::w2s(ctx, transformed[5], &brt) ||
|
||||
!render::w2s(ctx,transformed[0], &blb) || !render::w2s(ctx,transformed[4], &frt) ||
|
||||
!render::w2s(ctx,transformed[2], &frb) || !render::w2s(ctx,transformed[1], &brb) ||
|
||||
!render::w2s(ctx,transformed[6], &blt) || !render::w2s(ctx,transformed[7], &flt))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
Vector3D position_array[num_transformations] = {flb, brt, blb, frt, frb, brb, blt, flt};
|
||||
|
||||
float left = flb.x;
|
||||
float top = flb.y;
|
||||
float right = flb.x;
|
||||
float bottom = flb.y;
|
||||
|
||||
for (auto &index : position_array)
|
||||
{
|
||||
if (left > index.x)
|
||||
{
|
||||
left = index.x;
|
||||
}
|
||||
|
||||
if (right < index.x)
|
||||
{
|
||||
right = index.x;
|
||||
}
|
||||
|
||||
if (top < index.y)
|
||||
{
|
||||
top = index.y;
|
||||
}
|
||||
|
||||
if (bottom > index.y)
|
||||
{
|
||||
bottom = index.y;
|
||||
}
|
||||
}
|
||||
|
||||
out.x = left;
|
||||
out.y = bottom;
|
||||
out.w = (right - left);
|
||||
out.h = (top - bottom);
|
||||
|
||||
return true;
|
||||
}
|
||||
Reference in New Issue
Block a user