perf(content): remove exception-driven setup probes
This commit is contained in:
parent
f05afc07c1
commit
230a7df454
11 changed files with 598 additions and 47 deletions
|
|
@ -1,4 +1,5 @@
|
|||
using System.Numerics;
|
||||
using AcDream.Content;
|
||||
using AcDream.App.Diagnostics;
|
||||
using AcDream.App.Input;
|
||||
using AcDream.App.Interaction;
|
||||
|
|
@ -196,11 +197,35 @@ internal sealed class LivePresentationCompositionPhase
|
|||
var componentLifecycle =
|
||||
new DeferredLiveEntityRuntimeComponentLifecycle();
|
||||
var wbSpawnAdapter = new LandblockSpawnAdapter(foundation.MeshAdapter);
|
||||
Setup? LoadPreparedSetup(uint sourceId)
|
||||
{
|
||||
if (!content.Dats.TryResolvePreferred(
|
||||
sourceId,
|
||||
out IDatDatabase? database,
|
||||
out DatReaderWriter.Enums.DBObjType type)
|
||||
|| type != DatReaderWriter.Enums.DBObjType.Setup)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return database.TryGet<Setup>(
|
||||
sourceId,
|
||||
out Setup? setup)
|
||||
? setup
|
||||
: null;
|
||||
}
|
||||
|
||||
var setupResolver = new PreparedSetupResolver(
|
||||
content.PreparedAssets,
|
||||
LoadPreparedSetup,
|
||||
message => Console.Error.WriteLine(
|
||||
$"setup activation: {message}"));
|
||||
|
||||
AnimationSequencer SequencerFactory(WorldEntity entity)
|
||||
{
|
||||
Setup? setup = content.Dats.Get<Setup>(entity.SourceGfxObjOrSetupId);
|
||||
if (setup is not null)
|
||||
if (setupResolver.TryResolve(
|
||||
entity.SourceGfxObjOrSetupId,
|
||||
out Setup? setup))
|
||||
{
|
||||
uint motionTableId = (uint)setup.DefaultMotionTable;
|
||||
if (motionTableId != 0
|
||||
|
|
@ -247,38 +272,33 @@ internal sealed class LivePresentationCompositionPhase
|
|||
|
||||
ScriptActivationInfo? ResolveActivation(WorldEntity entity)
|
||||
{
|
||||
try
|
||||
{
|
||||
Setup? setup = content.Dats.Get<Setup>(
|
||||
entity.SourceGfxObjOrSetupId);
|
||||
if (setup is null)
|
||||
return null;
|
||||
uint scriptId = setup.DefaultScript.DataId;
|
||||
if (entity.IndexedPartTransforms.Count == 0)
|
||||
{
|
||||
var indexed = IndexedSetupPartPoseBuilder.Build(setup, entity);
|
||||
entity.SetIndexedPartPoses(indexed.Poses, indexed.Available);
|
||||
}
|
||||
|
||||
bool usesStaticAnimationWorkset = entity.ServerGuid == 0
|
||||
|| (liveEntities?.TryGetRecord(
|
||||
entity.ServerGuid,
|
||||
out LiveEntityRecord liveRecord) == true
|
||||
&& (liveRecord.FinalPhysicsState
|
||||
& PhysicsStateFlags.Static) != 0);
|
||||
return new ScriptActivationInfo(
|
||||
scriptId,
|
||||
entity.IndexedPartTransforms,
|
||||
EntityEffectProfile.CreateDatStatic(setup),
|
||||
entity.IndexedPartAvailable,
|
||||
setup,
|
||||
(uint)setup.DefaultAnimation,
|
||||
usesStaticAnimationWorkset);
|
||||
}
|
||||
catch
|
||||
if (!setupResolver.TryResolve(
|
||||
entity.SourceGfxObjOrSetupId,
|
||||
out Setup? setup))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
uint scriptId = setup.DefaultScript.DataId;
|
||||
if (entity.IndexedPartTransforms.Count == 0)
|
||||
{
|
||||
var indexed = IndexedSetupPartPoseBuilder.Build(setup, entity);
|
||||
entity.SetIndexedPartPoses(indexed.Poses, indexed.Available);
|
||||
}
|
||||
|
||||
bool usesStaticAnimationWorkset = entity.ServerGuid == 0
|
||||
|| (liveEntities?.TryGetRecord(
|
||||
entity.ServerGuid,
|
||||
out LiveEntityRecord liveRecord) == true
|
||||
&& (liveRecord.FinalPhysicsState
|
||||
& PhysicsStateFlags.Static) != 0);
|
||||
return new ScriptActivationInfo(
|
||||
scriptId,
|
||||
entity.IndexedPartTransforms,
|
||||
EntityEffectProfile.CreateDatStatic(setup),
|
||||
entity.IndexedPartAvailable,
|
||||
setup,
|
||||
(uint)setup.DefaultAnimation,
|
||||
usesStaticAnimationWorkset);
|
||||
}
|
||||
|
||||
var entityScriptActivator = new EntityScriptActivator(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue