Skip to content

Commit

Permalink
module_world_debug: optimilization + fixed entry point for Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
Marcin Gomulak committed Mar 6, 2019
1 parent eea312a commit d50a71b
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 9 deletions.
30 changes: 28 additions & 2 deletions FF8/FF8.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,29 @@
<TargetFrameworkProfile />
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
<UpdateEnabled>false</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
<UpdateInterval>7</UpdateInterval>
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<IsWebBootstrapper>false</IsWebBootstrapper>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<PlatformTarget>x86</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\$(MonoGamePlatform)\$(Platform)\$(Configuration)\</OutputPath>
<DefineConstants>DEBUG;TRACE;WINDOWS;</DefineConstants>
<DefineConstants>TRACE;_WINDOWS;DEBUG</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
Expand Down Expand Up @@ -109,7 +124,18 @@
<None Include="app.manifest" />
<None Include="packages.config" />
</ItemGroup>
<ItemGroup />
<ItemGroup>
<BootstrapperPackage Include=".NETFramework,Version=v4.6">
<Visible>False</Visible>
<ProductName>Microsoft .NET Framework 4.6 %28x86 i x64%29</ProductName>
<Install>true</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1</ProductName>
<Install>false</Install>
</BootstrapperPackage>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="$(MSBuildExtensionsPath)\MonoGame\v3.0\MonoGame.Content.Builder.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Expand Down
8 changes: 8 additions & 0 deletions FF8/FF8.csproj.user
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,13 @@
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ProjectView>ShowAllFiles</ProjectView>
<PublishUrlHistory>publish\</PublishUrlHistory>
<InstallUrlHistory />
<SupportUrlHistory />
<UpdateUrlHistory />
<BootstrapperUrlHistory />
<ErrorReportUrlHistory />
<FallbackCulture>pl-PL</FallbackCulture>
<VerifyUploadedFiles>false</VerifyUploadedFiles>
</PropertyGroup>
</Project>
10 changes: 10 additions & 0 deletions FF8/MakiExtended.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,11 @@ class MakiExtended
public static string GetUnixFullPath(string pt)
{
#if _WINDOWS
<<<<<<< Updated upstream
return System.IO.Path.GetFullPath(pt.Replace('/','\\'));
=======
return System.IO.Path.GetFullPath(pt.Replace('/', '\\'));
>>>>>>> Stashed changes
#else
return System.IO.Path.GetFullPath(pt.Replace("\\", "/"));
#endif
Expand All @@ -66,5 +70,11 @@ public static uint UintLittleEndian(uint uint_)
public static int UintLittleEndian(int uint_)
=> (uint_ << 24) | ((uint_ << 8) & 0x00FF0000) |
((uint_ >> 8) & 0x0000FF00) | (uint_ >> 24);

public static int ClampOverload(int a, int min, int max)
=> a < min ? max - Math.Abs(a) : a > max ? a - max : a;

public static float ClampOverload(float a, float min, float max)
=> a < min ? max - Math.Abs(a) : a > max ? a - max : a;
}
}
2 changes: 1 addition & 1 deletion FF8/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace FF8
{
#if WINDOWS || LINUX
#if _WINDOWS || LINUX
/// <summary>
/// The main class.
/// </summary>
Expand Down
35 changes: 29 additions & 6 deletions FF8/module_world_debug.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ class Module_world_debug
{
private static Matrix projectionMatrix, viewMatrix, worldMatrix;
private static float degrees, Yshift;
private static float camDistance = 10.0f;
private static readonly float camDistance = 10.0f;
private static readonly float renderCamDistance = 1200.0f;
private static Vector3 camPosition, camTarget;
public static BasicEffect effect;
public static AlphaTestEffect ate;
Expand All @@ -41,16 +42,15 @@ private enum MiniMapState
private static List<Texture2D[]> wm39textures;
private static List<Texture2D[]> charaOneTextures;
private static readonly int renderDistance = 4;
private static readonly float FOV = 60;

private static Vector2 segmentPosition;

private static Debug_MCH[] mchEntities;

private static byte[] wmx;

#if DEBUG
static float DEBUGshit = 0.0f;
#endif
static float DEBUGshit = FOV;

private static int GetSegment(int segID) => segID * 0x9000;

Expand Down Expand Up @@ -411,6 +411,9 @@ public static void Draw()
if (Input.GetInputDelayed(Keys.J))
MapState = MapState >= MiniMapState.fullscreen ? MapState = 0 : MapState + 1;

if (Input.GetInputDelayed(Keys.F1))
;




Expand All @@ -433,6 +436,7 @@ public static void Draw()
Memory.font.RenderBasicText(Font.CipherDirty($"World Map Camera: X={camPosition}"), 0, 30, 1, 1, 0, 1);
Memory.font.RenderBasicText(Font.CipherDirty($"Segment Position: ={segmentPosition}"), 0, 30 * 2, 1, 1, 0, 1);
Memory.font.RenderBasicText(Font.CipherDirty($"FPS camera deegress: ={degrees}"), 0, 30 * 3, 1, 1, 0, 1);
Memory.font.RenderBasicText(Font.CipherDirty($"var1: ={FOV}"), 0, 30 * 4, 1, 1, 0, 1);
Memory.SpriteBatchEnd();


Expand Down Expand Up @@ -572,7 +576,27 @@ private static void DrawSegment(int _i)
(seg.block[i].vertices[seg.block[i].polygons[k / 3].F3].Y + localZ) / WORLD_SCALE_MODEL + baseY),
new Vector2(seg.block[i].polygons[k / 3].U3 / 256.0f, seg.block[i].polygons[k / 3].V3 / 256.0f));

if (MakiExtended.Distance3D(camPosition, vpc[k].Position) > 1200.0f)
if (MakiExtended.Distance3D(camPosition, vpc[k].Position) > renderCamDistance)
continue;

float ax, ay, px, py, d1, d2, d3;

px = vpc[k].Position.X;
py = vpc[k].Position.Z;
ax = camPosition.X + (float)Math.Cos(MathHelper.ToRadians(degrees)) * -50f;
ay = camPosition.Z + (float)Math.Sin(MathHelper.ToRadians(degrees)) * -50f;

Vector3 left=Vector3.Zero,right = Vector3.Zero;
left.X = camPosition.X + (float)Math.Cos(MathHelper.ToRadians(MakiExtended.ClampOverload(degrees-FOV, 0, 359))) * renderCamDistance*2;
left.Z = camPosition.Z + (float)Math.Sin(MathHelper.ToRadians(MakiExtended.ClampOverload(degrees-FOV, 0, 359))) * renderCamDistance*2;
right.X = camPosition.X + (float)Math.Cos(MathHelper.ToRadians(MakiExtended.ClampOverload(degrees + FOV, 0, 359))) * renderCamDistance*2;
right.Z = camPosition.Z + (float)Math.Sin(MathHelper.ToRadians(MakiExtended.ClampOverload(degrees + FOV, 0, 359))) * renderCamDistance*2;

d1 = px * (ay - left.Z) + py * (left.X - ax) + (ax * left.Z - ay * left.X);
d2 = px * (left.Z - right.Z) + py * (right.X - left.X) + (left.X * right.Z - left.Z * right.X);
d3 = px * (right.Z - ay) + py * (ax - right.X) + (right.X * ay - right.Z * ax);

if ((d1 > 0 || d2 > 0 || d3 > 0) && (d1 < 0 || d2 < 0 || d3 < 0))
continue;

if (seg.block[i].polygons[k / 3].TextureSwitch == 0x40 ||
Expand All @@ -593,7 +617,6 @@ private static void DrawSegment(int _i)
{
pass.Apply();
Memory.graphics.GraphicsDevice.DrawUserPrimitives(PrimitiveType.TriangleList, vpc, k, 1);

}
}
}
Expand Down

0 comments on commit d50a71b

Please sign in to comment.