Fix active vectors in input proxy referring to temporary property sources.

This commit is contained in:
2023-05-19 00:45:14 +08:00
parent 5d520609b5
commit 5bed3cf05b

View File

@@ -199,6 +199,11 @@ namespace Cryville.Crtr {
}
}
public bool IsNull { get; set; }
public RVector4 Get() {
fixed (byte* _ptr = buf) {
return *(RVector4*)_ptr;
}
}
public void Set(RVector4 vec) {
fixed (byte* _ptr = buf) {
*(RVector4*)_ptr = vec;
@@ -239,7 +244,7 @@ namespace Cryville.Crtr {
readonly Dictionary<InputHandler, double> _timeOrigins = new Dictionary<InputHandler, double>();
readonly Dictionary<Identifier, int> _targetActiveCount = new Dictionary<Identifier, int>();
readonly Dictionary<InputIdentifier, float> _vect = new Dictionary<InputIdentifier, float>();
readonly Dictionary<ProxiedInputIdentifier, PropSrc> _vecs = new Dictionary<ProxiedInputIdentifier, PropSrc>();
readonly Dictionary<ProxiedInputIdentifier, Vector4> _vecs = new Dictionary<ProxiedInputIdentifier, Vector4>();
double? _lockTime = null;
unsafe void OnInput(InputIdentifier id, InputFrame frame) {
var rc = id.Source.Handler.ReferenceCue;
@@ -281,7 +286,7 @@ namespace Cryville.Crtr {
}
static readonly int _var_fv = IdentifierManager.Shared.Request("input_vec_from");
static readonly int _var_tv = IdentifierManager.Shared.Request("input_vec_to");
unsafe void OnInput(InputIdentifier id, Identifier target, float ft, float tt, bool nullflag, int depth = 0) {
readonly InputVectorSrc _vecsrc = new InputVectorSrc();
if (depth >= MAX_DEPTH) throw new InputProxyException("Input propagation limit reached\nThe ruleset has invalid input definitions");
var def = _ruleset.inputs[target];
if (def.pass != null) {
@@ -301,7 +306,12 @@ namespace Cryville.Crtr {
else {
var pid = new ProxiedInputIdentifier { Source = id, Target = target };
PropSrc fv, tv = _etor.ContextCascadeLookup(_var_input_vec);
if (!_vecs.TryGetValue(pid, out fv)) fv = PropSrc.Null;
bool hfv; Vector4 ifv;
if (hfv = _vecs.TryGetValue(pid, out ifv)) {
_vecsrc.Set(ifv);
fv = _vecsrc;
}
else fv = PropSrc.Null;
if (fv.Type != PdtInternalType.Null || tv.Type != PdtInternalType.Null) {
if (fv.Type == PdtInternalType.Null) {
_targetActiveCount[target]++;
@@ -315,7 +325,10 @@ namespace Cryville.Crtr {
_vecs.Remove(pid);
_targetActiveCount[target]--;
}
else _vecs[pid] = tv;
else {
var itv = ((InputVectorSrc)tv).Get();
if (!hfv || _vecs[pid] != itv) _vecs[pid] = itv;
}
}
}
}