Modify logic for "and" and "or" operator and in_area function. Add null marshaling for input proxy.

This commit is contained in:
2022-11-06 14:52:05 +08:00
parent 71a33c0b43
commit 65d86ed72d
2 changed files with 8 additions and 3 deletions

View File

@@ -117,10 +117,15 @@ namespace Cryville.Crtr {
readonly byte[] _vecbuf = new byte[3 * sizeof(float) + sizeof(int)];
unsafe void OnInput(InputIdentifier id, InputVector vec, string target) {
_etor.ContextCascadeInsert();
if (vec.IsNull) {
_etor.ContextCascadeUpdate(_var_value, new PropSrc.Arbitrary(PdtInternalType.Null, new byte[0]));
}
else {
fixed (byte* ptr = _vecbuf) {
*(Vector3*)ptr = vec.Vector;
}
_etor.ContextCascadeUpdate(_var_value, new PropSrc.Arbitrary(PdtInternalType.Vector, _vecbuf));
}
OnInput(id, target);
_etor.ContextCascadeDiscard();
}

View File

@@ -87,8 +87,8 @@ namespace Cryville.Crtr {
static readonly int _colop_and = IdentifierManager.SharedInstance.Request("&");
static readonly int _colop_or = IdentifierManager.SharedInstance.Request("|");
protected override bool Collapse(int name, PdtVariableMemory param) {
if (name == _colop_and) return param.AsNumber() == 0;
else if(name == _colop_or) return param.AsNumber() != 0;
if (name == _colop_and) return param.AsNumber() <= 0;
else if (name == _colop_or) return param.AsNumber() > 0;
else throw new KeyNotFoundException(string.Format("Undefined collapse operator {0}", name));
}
@@ -391,7 +391,7 @@ namespace Cryville.Crtr {
if (arg.Type == PdtInternalType.Error) {
throw new InvalidOperationException("Error");
}
else if (arg.Type == PdtInternalType.Number && arg.AsNumber() >= 0) {
else if (arg.Type == PdtInternalType.Number && arg.AsNumber() <= 0) {
GetReturnFrame(PdtInternalType.Null, 0);
}
else {