mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-17 03:25:14 -04:00
Combine some headers, part 2
This commit is contained in:
parent
880cbbd0a6
commit
fdd620aba6
@ -38,10 +38,10 @@ namespace ClassicalSharp.Gui.Screens {
|
||||
|
||||
buttons = new ButtonWidget[] {
|
||||
MakeText(0, -100, Get(0)),
|
||||
MakeText(0, -50, Get(1)),
|
||||
MakeText(0, 0, Get(2)),
|
||||
MakeText(0, 50, Get(3)),
|
||||
MakeText(0, 100, Get(4)),
|
||||
MakeText(0, -50, Get(1)),
|
||||
MakeText(0, 0, Get(2)),
|
||||
MakeText(0, 50, Get(3)),
|
||||
MakeText(0, 100, Get(4)),
|
||||
|
||||
Make(-220, 0, "<", MoveBackwards),
|
||||
Make(220, 0, ">", MoveForwards),
|
||||
|
@ -17,20 +17,17 @@ namespace ClassicalSharp.Gui.Screens {
|
||||
|
||||
public override void Render(double delta) {
|
||||
RenderMenuBounds();
|
||||
int extClipY = extendedHelp == null ? 0 : widgets[widgets.Length - 3].Y;
|
||||
int extEndY = extendedHelp == null ? 0 : extendedHelp.Y + extendedHelp.Height;
|
||||
|
||||
if (extendedHelp != null && extEndY <= extClipY) {
|
||||
int tableWidth = extendedHelp.Width, tableHeight = extendedHelp.Height;
|
||||
int x = game.Width / 2 - tableWidth / 2 - 5;
|
||||
int y = game.Height / 2 + extHelpY - 5;
|
||||
game.Graphics.Draw2DQuad(x, y, tableWidth + 10, tableHeight + 10, tableCol);
|
||||
}
|
||||
|
||||
game.Graphics.Texturing = true;
|
||||
RenderWidgets(widgets, delta);
|
||||
|
||||
if (extendedHelp != null && extEndY <= extClipY) {
|
||||
if (extendedHelp != null) {
|
||||
game.Graphics.Texturing = false;
|
||||
int tableWidth = extendedHelp.Width, tableHeight = extendedHelp.Height;
|
||||
int x = game.Width / 2 - tableWidth / 2 - 5;
|
||||
int y = game.Height / 2 + extHelpY - 5;
|
||||
|
||||
game.Graphics.Draw2DQuad(x, y, tableWidth + 10, tableHeight + 10, tableCol);
|
||||
game.Graphics.Texturing = true;
|
||||
extendedHelp.Render(delta);
|
||||
}
|
||||
game.Graphics.Texturing = false;
|
||||
|
@ -107,7 +107,7 @@ namespace ClassicalSharp.Gui.Screens {
|
||||
game.Events.HackPermissionsChanged -= CheckHacksAllowed;
|
||||
}
|
||||
|
||||
static string[] descriptions = {
|
||||
static string[] descriptions = new string[] {
|
||||
"&eMusic/Sound, view bobbing, and more",
|
||||
"&eChat options, gui scale, font settings, and more",
|
||||
"&eFPS limit, view distance, entity names/shadows",
|
||||
|
@ -411,7 +411,7 @@ namespace ClassicalSharp.Gui.Widgets {
|
||||
UpdateCaret();
|
||||
}
|
||||
|
||||
static char[] trimChars = {'\r', '\n', '\v', '\f', ' ', '\t', '\0'};
|
||||
static char[] trimChars = new char[] {'\r', '\n', '\v', '\f', ' ', '\t', '\0'};
|
||||
bool OtherKey(Key key) {
|
||||
int maxChars = UsedLines * MaxCharsPerLine;
|
||||
if (key == Key.V && Text.Length < maxChars) {
|
||||
|
@ -73,7 +73,7 @@ namespace ClassicalSharp.Commands {
|
||||
return match;
|
||||
}
|
||||
|
||||
static char[] splitChar = { ' ' };
|
||||
static char[] splitChar = new char[] { ' ' };
|
||||
public void Execute(string text) {
|
||||
if (Utils.CaselessStarts(text, prefixSpace)) { // /client command args
|
||||
text = text.Substring(prefixSpace.Length);
|
||||
|
@ -195,7 +195,7 @@ namespace ClassicalSharp.GraphicsAPI {
|
||||
/// <summary> Optimised version of DrawIndexedVb for VertexFormat.Pos3fTex2fCol4b </summary>
|
||||
internal abstract void DrawIndexedVb_TrisT2fC4b(int verticesCount, int startVertex);
|
||||
|
||||
protected static int[] strideSizes = { 16, 24 };
|
||||
protected static int[] strideSizes = new int[] { 16, 24 };
|
||||
|
||||
|
||||
/// <summary> Sets the matrix type that load/push/pop operations should be applied to. </summary>
|
||||
|
@ -454,7 +454,7 @@ namespace ClassicalSharp {
|
||||
return flags;
|
||||
}
|
||||
|
||||
static int[] masks = {
|
||||
static int[] masks = new int[] {
|
||||
// Left face
|
||||
(1 << xM1_yM1_zM1) | (1 << xM1_yM1_zCC) | (1 << xM1_yM1_zP1) |
|
||||
(1 << xM1_yCC_zM1) | (1 << xM1_yCC_zCC) | (1 << xM1_yCC_zP1) |
|
||||
|
@ -87,7 +87,7 @@ namespace ClassicalSharp.Network {
|
||||
#endif
|
||||
}
|
||||
|
||||
public static string[] ClientExtensions = {
|
||||
public static string[] ClientExtensions = new string[] {
|
||||
"ClickDistance", "CustomBlocks", "HeldBlock", "EmoteFix", "TextHotKey", "ExtPlayerList",
|
||||
"EnvColors", "SelectionCuboid", "BlockPermissions", "ChangeModel", "EnvMapAppearance",
|
||||
"EnvWeatherType", "MessageTypes", "HackControl", "PlayerClick", "FullCP437",
|
||||
|
@ -2,7 +2,6 @@
|
||||
#include "Constants.h"
|
||||
#include "Event.h"
|
||||
#include "ExtMath.h"
|
||||
#include "FrustumCulling.h"
|
||||
#include "Funcs.h"
|
||||
#include "Game.h"
|
||||
#include "GraphicsAPI.h"
|
||||
|
@ -2,7 +2,6 @@
|
||||
#define CC_CHUNKUPDATER_H
|
||||
#include "Typedefs.h"
|
||||
#include "Vectors.h"
|
||||
#include "Event.h"
|
||||
/* Manages the process of building/deleting chunk meshes.
|
||||
Also sorts chunks so nearest chunks are ordered first, and calculates chunk visibility.
|
||||
Copyright 2014-2017 ClassicalSharp | Licensed under BSD-3
|
||||
|
@ -199,7 +199,6 @@
|
||||
<ClInclude Include="ErrorHandler.h" />
|
||||
<ClInclude Include="Event.h" />
|
||||
<ClInclude Include="Formats.h" />
|
||||
<ClInclude Include="FrustumCulling.h" />
|
||||
<ClInclude Include="Deflate.h" />
|
||||
<ClInclude Include="GameMode.h" />
|
||||
<ClInclude Include="Gui.h" />
|
||||
@ -281,7 +280,6 @@
|
||||
<ClCompile Include="InputHandler.c" />
|
||||
<ClCompile Include="Inventory.c" />
|
||||
<ClCompile Include="MapGenerator.c" />
|
||||
<ClCompile Include="FrustumCulling.c" />
|
||||
<ClCompile Include="GameStructs.c" />
|
||||
<ClCompile Include="Deflate.c" />
|
||||
<ClCompile Include="IModel.c" />
|
||||
|
@ -210,9 +210,6 @@
|
||||
<ClInclude Include="Drawer.h">
|
||||
<Filter>Header Files\MeshBuilder</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="FrustumCulling.h">
|
||||
<Filter>Header Files\Rendering</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Stream.h">
|
||||
<Filter>Header Files\IO</Filter>
|
||||
</ClInclude>
|
||||
@ -422,9 +419,6 @@
|
||||
<ClCompile Include="Drawer.c">
|
||||
<Filter>Source Files\MeshBuilder</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="FrustumCulling.c">
|
||||
<Filter>Source Files\Rendering</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Stream.c">
|
||||
<Filter>Source Files\IO</Filter>
|
||||
</ClCompile>
|
||||
|
@ -1,81 +0,0 @@
|
||||
#include "FrustumCulling.h"
|
||||
#include "ExtMath.h"
|
||||
|
||||
Real32
|
||||
frustum00, frustum01, frustum02, frustum03,
|
||||
frustum10, frustum11, frustum12, frustum13,
|
||||
frustum20, frustum21, frustum22, frustum23,
|
||||
frustum30, frustum31, frustum32, frustum33,
|
||||
frustum40, frustum41, frustum42, frustum43;
|
||||
|
||||
void FrustumCulling_Normalise(Real32* plane0, Real32* plane1, Real32* plane2, Real32* plane3) {
|
||||
Real32 val1 = *plane0;
|
||||
Real32 val2 = *plane1;
|
||||
Real32 val3 = *plane2;
|
||||
Real32 t = (Real32)Math_Sqrt(val1 * val1 + val2 * val2 + val3 * val3);
|
||||
|
||||
*plane0 /= t;
|
||||
*plane1 /= t;
|
||||
*plane2 /= t;
|
||||
*plane3 /= t;
|
||||
}
|
||||
|
||||
bool FrustumCulling_SphereInFrustum(Real32 x, Real32 y, Real32 z, Real32 radius) {
|
||||
Real32 d = frustum00 * x + frustum01 * y + frustum02 * z + frustum03;
|
||||
if (d <= -radius) return false;
|
||||
|
||||
d = frustum10 * x + frustum11 * y + frustum12 * z + frustum13;
|
||||
if (d <= -radius) return false;
|
||||
|
||||
d = frustum20 * x + frustum21 * y + frustum22 * z + frustum23;
|
||||
if (d <= -radius) return false;
|
||||
|
||||
d = frustum30 * x + frustum31 * y + frustum32 * z + frustum33;
|
||||
if (d <= -radius) return false;
|
||||
|
||||
d = frustum40 * x + frustum41 * y + frustum42 * z + frustum43;
|
||||
if (d <= -radius) return false;
|
||||
/* Don't test NEAR plane, it's pointless */
|
||||
return true;
|
||||
}
|
||||
|
||||
void FrustumCulling_CalcFrustumEquations(Matrix* projection, Matrix* modelView) {
|
||||
Matrix clipMatrix;
|
||||
Matrix_Mul(&clipMatrix, modelView, projection);
|
||||
|
||||
Real32* clip = (Real32*)&clipMatrix;
|
||||
/* Extract the numbers for the RIGHT plane */
|
||||
frustum00 = clip[3] - clip[0];
|
||||
frustum01 = clip[7] - clip[4];
|
||||
frustum02 = clip[11] - clip[8];
|
||||
frustum03 = clip[15] - clip[12];
|
||||
FrustumCulling_Normalise(&frustum00, &frustum01, &frustum02, &frustum03);
|
||||
|
||||
/* Extract the numbers for the LEFT plane */
|
||||
frustum10 = clip[3] + clip[0];
|
||||
frustum11 = clip[7] + clip[4];
|
||||
frustum12 = clip[11] + clip[8];
|
||||
frustum13 = clip[15] + clip[12];
|
||||
FrustumCulling_Normalise(&frustum10, &frustum11, &frustum12, &frustum13);
|
||||
|
||||
/* Extract the BOTTOM plane */
|
||||
frustum20 = clip[3] + clip[1];
|
||||
frustum21 = clip[7] + clip[5];
|
||||
frustum22 = clip[11] + clip[9];
|
||||
frustum23 = clip[15] + clip[13];
|
||||
FrustumCulling_Normalise(&frustum20, &frustum21, &frustum22, &frustum23);
|
||||
|
||||
/* Extract the TOP plane */
|
||||
frustum30 = clip[3] - clip[1];
|
||||
frustum31 = clip[7] - clip[5];
|
||||
frustum32 = clip[11] - clip[9];
|
||||
frustum33 = clip[15] - clip[13];
|
||||
FrustumCulling_Normalise(&frustum30, &frustum31, &frustum32, &frustum33);
|
||||
|
||||
/* Extract the FAR plane */
|
||||
frustum40 = clip[3] - clip[2];
|
||||
frustum41 = clip[7] - clip[6];
|
||||
frustum42 = clip[11] - clip[10];
|
||||
frustum43 = clip[15] - clip[14];
|
||||
FrustumCulling_Normalise(&frustum40, &frustum41, &frustum42, &frustum43);
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
#ifndef CC_FRUSTUMCULLING_H
|
||||
#define CC_FRUSTUMCULLING_H
|
||||
#include "Vectors.h"
|
||||
#include "Typedefs.h"
|
||||
/* Implements frustum culling of bounding spheres.
|
||||
Copyright 2014-2017 ClassicalSharp | Licensed under BSD-3
|
||||
Sourced from http://www.crownandcutlass.com/features/technicaldetails/frustum.html
|
||||
*/
|
||||
|
||||
/* Returns whether the given bounding sphere is in the view frustum. */
|
||||
bool FrustumCulling_SphereInFrustum(Real32 x, Real32 y, Real32 z, Real32 radius);
|
||||
/* Calculates the planes that constitute view frustum. */
|
||||
void FrustumCulling_CalcFrustumEquations(Matrix* projection, Matrix* modelView);
|
||||
#endif
|
@ -4,7 +4,6 @@
|
||||
#include "Game.h"
|
||||
#include "ModelCache.h"
|
||||
#include "GraphicsCommon.h"
|
||||
#include "FrustumCulling.h"
|
||||
#include "GraphicsAPI.h"
|
||||
|
||||
#define UV_POS_MASK ((UInt16)0x7FFF)
|
||||
|
@ -291,4 +291,77 @@ void Matrix_LookAt(Matrix* result, Vector3 eye, Vector3 target, Vector3 up) {
|
||||
result->Row3.Y = -Vector3_Dot(&y, &eye);
|
||||
result->Row3.Z = -Vector3_Dot(&z, &eye);
|
||||
result->Row3.W = 1.0f;
|
||||
}
|
||||
|
||||
Real32
|
||||
frustum00, frustum01, frustum02, frustum03,
|
||||
frustum10, frustum11, frustum12, frustum13,
|
||||
frustum20, frustum21, frustum22, frustum23,
|
||||
frustum30, frustum31, frustum32, frustum33,
|
||||
frustum40, frustum41, frustum42, frustum43;
|
||||
|
||||
void FrustumCulling_Normalise(Real32* plane0, Real32* plane1, Real32* plane2, Real32* plane3) {
|
||||
Real32 val1 = *plane0, val2 = *plane1, val3 = *plane2;
|
||||
Real32 t = Math_Sqrt(val1 * val1 + val2 * val2 + val3 * val3);
|
||||
*plane0 /= t; *plane1 /= t; *plane2 /= t; *plane3 /= t;
|
||||
}
|
||||
|
||||
bool FrustumCulling_SphereInFrustum(Real32 x, Real32 y, Real32 z, Real32 radius) {
|
||||
Real32 d = frustum00 * x + frustum01 * y + frustum02 * z + frustum03;
|
||||
if (d <= -radius) return false;
|
||||
|
||||
d = frustum10 * x + frustum11 * y + frustum12 * z + frustum13;
|
||||
if (d <= -radius) return false;
|
||||
|
||||
d = frustum20 * x + frustum21 * y + frustum22 * z + frustum23;
|
||||
if (d <= -radius) return false;
|
||||
|
||||
d = frustum30 * x + frustum31 * y + frustum32 * z + frustum33;
|
||||
if (d <= -radius) return false;
|
||||
|
||||
d = frustum40 * x + frustum41 * y + frustum42 * z + frustum43;
|
||||
if (d <= -radius) return false;
|
||||
/* Don't test NEAR plane, it's pointless */
|
||||
return true;
|
||||
}
|
||||
|
||||
void FrustumCulling_CalcFrustumEquations(Matrix* projection, Matrix* modelView) {
|
||||
Matrix clipMatrix;
|
||||
Matrix_Mul(&clipMatrix, modelView, projection);
|
||||
|
||||
Real32* clip = (Real32*)&clipMatrix;
|
||||
/* Extract the numbers for the RIGHT plane */
|
||||
frustum00 = clip[3] - clip[0];
|
||||
frustum01 = clip[7] - clip[4];
|
||||
frustum02 = clip[11] - clip[8];
|
||||
frustum03 = clip[15] - clip[12];
|
||||
FrustumCulling_Normalise(&frustum00, &frustum01, &frustum02, &frustum03);
|
||||
|
||||
/* Extract the numbers for the LEFT plane */
|
||||
frustum10 = clip[3] + clip[0];
|
||||
frustum11 = clip[7] + clip[4];
|
||||
frustum12 = clip[11] + clip[8];
|
||||
frustum13 = clip[15] + clip[12];
|
||||
FrustumCulling_Normalise(&frustum10, &frustum11, &frustum12, &frustum13);
|
||||
|
||||
/* Extract the BOTTOM plane */
|
||||
frustum20 = clip[3] + clip[1];
|
||||
frustum21 = clip[7] + clip[5];
|
||||
frustum22 = clip[11] + clip[9];
|
||||
frustum23 = clip[15] + clip[13];
|
||||
FrustumCulling_Normalise(&frustum20, &frustum21, &frustum22, &frustum23);
|
||||
|
||||
/* Extract the TOP plane */
|
||||
frustum30 = clip[3] - clip[1];
|
||||
frustum31 = clip[7] - clip[5];
|
||||
frustum32 = clip[11] - clip[9];
|
||||
frustum33 = clip[15] - clip[13];
|
||||
FrustumCulling_Normalise(&frustum30, &frustum31, &frustum32, &frustum33);
|
||||
|
||||
/* Extract the FAR plane */
|
||||
frustum40 = clip[3] - clip[2];
|
||||
frustum41 = clip[7] - clip[6];
|
||||
frustum42 = clip[11] - clip[10];
|
||||
frustum43 = clip[15] - clip[14];
|
||||
FrustumCulling_Normalise(&frustum40, &frustum41, &frustum42, &frustum43);
|
||||
}
|
@ -2,6 +2,7 @@
|
||||
#define CC_VECTORS_H
|
||||
#include "Typedefs.h"
|
||||
/* Represents 2, 3 dimensional vectors, and 4 x 4 matrix.
|
||||
Frustum culling sourced from http://www.crownandcutlass.com/features/technicaldetails/frustum.html
|
||||
Copyright 2017 ClassicalSharp | Licensed under BSD-3
|
||||
*/
|
||||
|
||||
@ -81,4 +82,7 @@ void Matrix_OrthographicOffCenter(Matrix* result, Real32 left, Real32 right, Rea
|
||||
void Matrix_PerspectiveFieldOfView(Matrix* result, Real32 fovy, Real32 aspect, Real32 zNear, Real32 zFar);
|
||||
void Matrix_PerspectiveOffCenter(Matrix* result, Real32 left, Real32 right, Real32 bottom, Real32 top, Real32 zNear, Real32 zFar);
|
||||
void Matrix_LookAt(Matrix* result, Vector3 eye, Vector3 target, Vector3 up);
|
||||
|
||||
bool FrustumCulling_SphereInFrustum(Real32 x, Real32 y, Real32 z, Real32 radius);
|
||||
void FrustumCulling_CalcFrustumEquations(Matrix* projection, Matrix* modelView);
|
||||
#endif
|
Loading…
x
Reference in New Issue
Block a user