This commit is contained in:
2024-04-26 20:06:38 +03:00
parent 0da7f2d93e
commit e023dfce69
21 changed files with 73 additions and 466 deletions

View File

@@ -51,7 +51,7 @@ public class CameraRender : PostProcessEffect
public override void OnAwake()
{
viewModelHolder = Parent.Parent.Parent.Parent.GetChild("ViewModelHolder");
if (useMainCamera)
if (useMainCamera && viewModelHolder != null)
{
camera.IsActive = false;
void foo(Actor actor)

View File

@@ -204,6 +204,7 @@ public class ConsoleInstance : IDisposable
// Initializes the Console system.
internal void InitConsoleSubsystems()
{
return;
#if USE_NETCORE
var assemblies = Utils.GetAssemblies();
#else

View File

@@ -159,6 +159,9 @@ public class ConsoleScript : Script
+ " long line in repeat a very very very long long long 4 line in repeat");
Console.Print("another normal line");*/
//for (int i=0; i<10000; i++)
// Debug.Log("a very very very long long long line in repeat a very very very long long long line in");
Debug.Logger.LogHandler.SendLog += OnSendLog;
Debug.Logger.LogHandler.SendExceptionLog += OnSendExceptionLog;

View File

@@ -19,15 +19,7 @@ public static partial class NetworkManager
public static bool ConnectServer(string serverAddress = "localhost", bool listenServer = false)
{
if (!listenServer)
{
Cleanup();
//WorldStateManager.Init();
clientWorldStateManager = new WorldStateManager(isClient: true);
}
else
{
clientWorldStateManager = new WorldStateManager(isLocalClient: true);
}
ServerAddress = serverAddress;
//var driver = Object.New(typeof(ENetDriver));
@@ -56,6 +48,17 @@ public static partial class NetworkManager
Console.Print("Failed to connect to the server.");
return false;
}
Debug.Log("Connected...");
if (!listenServer)
{
//WorldStateManager.Init();
clientWorldStateManager = new WorldStateManager(isClient: true);
}
else
{
clientWorldStateManager = new WorldStateManager(isLocalClient: true);
}
Scripting.FixedUpdate += OnClientNetworkUpdate;
if (!listenServer)

View File

@@ -99,6 +99,8 @@ public class WorldStateManager
else
NetworkManager.RegisterClientMessageCallback(OnMessage);
Debug.Log($"WorldStateManager Init is server: {IsServer}");
Debug.Log($"WorldStateManager Init is local client: {IsLocalClient}");
PhysicsScene localPhysicsScene = Physics.FindOrCreateScene(IsLocalClient ? "ClientPhysicsScene" : "ServerPhysicsScene");
@@ -158,7 +160,7 @@ public class WorldStateManager
var importer = FlaxEngine.Object.New<Q3MapImporter>();
importer.mapPath = @"C:\dev\GoakeFlax\Assets\Maps\aerowalk.map";
importer.LoadCollidersOnly = false;//IsServer;
importer.LoadCollidersOnly = IsServer;
importer.Parent = scene;
//importer.Enabled = true;
@@ -182,6 +184,13 @@ public class WorldStateManager
{
FlaxEngine.Object.Destroy(player);
}
if (scene)
{
if (Level.UnloadScene(scene))
throw new Exception("Failed to unload scene");
scene = null;
}
}
private PlayerFrame GetPlayerFrame(uint playerIndex, ulong playerFrameIndex)
@@ -256,7 +265,9 @@ public class WorldStateManager
//PlayerInputState inputState = playerMovement.input.GetCurrentInputState();
var playerFrame = playerLastFrame[playerId];
if (!playerMovement.input.GetState(playerFrame, out var inputState, out var actorState))
Console.Print("send input failure to client");
{
//Console.Print("send input failure to client");
}
{
NetworkMessage message = NetworkManager.ServerBeginSendMessage();

View File

@@ -53,7 +53,7 @@ public class PerformanceWidget : Script
StringBuilder text = new StringBuilder(10);
#if false
#if true
long triangles = 0;
long drawCalls = 0;
@@ -67,7 +67,7 @@ public class PerformanceWidget : Script
#endif
text.AppendLine($"{triangles} tris\n {drawCalls} drawcalls");
text.AppendLine($"{(int)Math.Round(1.0f / updateTimeAvg2)}fps2\n");
text.AppendLine($"{(int)Math.Round(1.0f / updateTimeAvg2)}fps2");
#endif
text.Append($"{(int)Math.Round(1.0f / updateTimeAvg)}fps");

View File

@@ -512,7 +512,6 @@ public class Q3MapImporter : Script
bool useStaticBatching = StaticBatching && !LoadCollidersOnly;
bool convexMesh = true;
FlaxEngine.Debug.Log("Loading map, static batching: " + useStaticBatching);
{
string matBasePath = Path.Combine(AssetManager.ContentPath, "Materials");
@@ -730,24 +729,24 @@ public class Q3MapImporter : Script
if (!LoadCollidersOnly)
{
geom.model = Content.CreateVirtualAsset<Model>();
geom.model.SetupLODs(new[] { geom.meshes.Length });
geom.model.SetupMaterialSlots(geom.meshes.Length);
geom.model = Content.CreateVirtualAsset<Model>();
geom.model.SetupLODs(new[] { geom.meshes.Length });
geom.model.SetupMaterialSlots(geom.meshes.Length);
for (int i = 0; i < geom.meshes.Length; i++)
{
BrushGeometryMesh mesh = geom.meshes[i];
if (mesh.vertices.Count == 0)
continue;
for (int i = 0; i < geom.meshes.Length; i++)
{
BrushGeometryMesh mesh = geom.meshes[i];
if (mesh.vertices.Count == 0)
continue;
geom.model.LODs[0].Meshes[i].UpdateMesh(mesh.vertices, mesh.indices, mesh.normals,
null, mesh.uvs);
geom.model.LODs[0].Meshes[i].MaterialSlotIndex = i;
geom.model.MaterialSlots[i].Material = geom.meshes[i].material;
}
geom.model.LODs[0].Meshes[i].UpdateMesh(mesh.vertices, mesh.indices, mesh.normals,
null, mesh.uvs);
geom.model.LODs[0].Meshes[i].MaterialSlotIndex = i;
geom.model.MaterialSlots[i].Material = geom.meshes[i].material;
}
//Not supported yet, should be done here
//geom.model.GenerateSDF();
//Not supported yet, should be done here
//geom.model.GenerateSDF();
}
brushIndex++;
@@ -1317,6 +1316,19 @@ public class Q3MapImporter : Script
Console.Print($"Generated level SDF in {sw2.Elapsed.TotalMilliseconds}ms");
});
}
//Content.AssetDisposing += Content_AssetDisposing;
//Content.AssetReloading += Content_AssetReloading;
}
private void Content_AssetReloading(Asset obj)
{
Debug.Log("asset reload: " + obj.Path + $" ({obj.TypeName})");
}
private void Content_AssetDisposing(Asset obj)
{
Debug.Log("asset disposing: " + obj.Path + $" ({obj.TypeName})");
}
private void ParseLight(MapEntity entity, ref int lightIndex)
@@ -1395,6 +1407,10 @@ public class Q3MapImporter : Script
light.ShadowsDistance = 500f;
light.ShadowsDepthBias = 0.027f;//0.005f;
#if FLAX_1_9_OR_NEWER
light.ShadowsUpdateRate = 0.0f;
#endif
int preset = 3;
if (preset == 0) // most accurate?, huge radius and low performance
{