mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-13 09:35:23 -04:00
Make selection box rendering a little bit faster
This commit is contained in:
parent
8ce836010a
commit
f475eec352
@ -1209,7 +1209,7 @@ static void GeneratingScreen_EndGeneration(void) {
|
||||
struct LocationUpdate update;
|
||||
float x, z;
|
||||
|
||||
Gui_Remove(LoadingScreen_UNSAFE_RawPointer);
|
||||
Gui_Remove((struct Screen*)&LoadingScreen_Instance);
|
||||
Gen_Done = false;
|
||||
|
||||
if (!Gen_Blocks) { Chat_AddRaw("&cFailed to generate the map."); return; }
|
||||
|
@ -37,6 +37,7 @@ extern struct Screen* LoadingScreen_UNSAFE_RawPointer;
|
||||
void ChatScreen_OpenInput(const String* text);
|
||||
/* Appends text to the chat input in the HUD. */
|
||||
void ChatScreen_AppendInput(const String* text);
|
||||
/* Sets number of visible lines in the main chat widget. */
|
||||
void ChatScreen_SetChatlines(int lines);
|
||||
struct Widget* ChatScreen_GetHotbar(void);
|
||||
#endif
|
||||
|
@ -82,20 +82,14 @@ static void SelectionBox_UpdateDist(Vec3 p, float x2, float y2, float z2, float*
|
||||
if (dist > *furthest) *furthest = dist;
|
||||
}
|
||||
|
||||
static void SelectionBox_Intersect(struct SelectionBox* box, Vec3 origin) {
|
||||
Vec3 min = box->Min, max = box->Max;
|
||||
float closest = MATH_POS_INF, furthest = -MATH_POS_INF;
|
||||
/* Bottom corners */
|
||||
SelectionBox_UpdateDist(origin, min.X, min.Y, min.Z, &closest, &furthest);
|
||||
SelectionBox_UpdateDist(origin, max.X, min.Y, min.Z, &closest, &furthest);
|
||||
SelectionBox_UpdateDist(origin, max.X, min.Y, max.Z, &closest, &furthest);
|
||||
SelectionBox_UpdateDist(origin, min.X, min.Y, max.Z, &closest, &furthest);
|
||||
/* Top corners */
|
||||
SelectionBox_UpdateDist(origin, min.X, max.Y, min.Z, &closest, &furthest);
|
||||
SelectionBox_UpdateDist(origin, max.X, max.Y, min.Z, &closest, &furthest);
|
||||
SelectionBox_UpdateDist(origin, max.X, max.Y, max.Z, &closest, &furthest);
|
||||
SelectionBox_UpdateDist(origin, min.X, max.Y, max.Z, &closest, &furthest);
|
||||
box->MinDist = closest; box->MaxDist = furthest;
|
||||
static void SelectionBox_Intersect(struct SelectionBox* box, Vec3 P) {
|
||||
float dx1 = (P.X - box->Min.X) * (P.X - box->Min.X), dx2 = (P.X - box->Max.X) * (P.X - box->Max.X);
|
||||
float dy1 = (P.Y - box->Min.Y) * (P.Y - box->Min.Y), dy2 = (P.Y - box->Max.Y) * (P.Y - box->Max.Y);
|
||||
float dz1 = (P.Z - box->Min.Z) * (P.Z - box->Min.Z), dz2 = (P.Z - box->Max.Z) * (P.Z - box->Max.Z);
|
||||
|
||||
/* Distance to closest and furthest of the eight box corners */
|
||||
box->MinDist = min(dx1, dx2) + min(dy1, dy2) + min(dz1, dz2);
|
||||
box->MaxDist = max(dx1, dx2) + max(dy1, dy2) + max(dz1, dz2);
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user