Skip to content

Commit edb7e2b

Browse files
Minor cleanups to quatresolverbase and vectorresolverbase.
1 parent 0f3b0e5 commit edb7e2b

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

Source/Data/Resolvers/QuaternionResolverBase.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,9 @@ protected override ReadResult _Internal_Read(ref BytePayloadReader reader, out T
5454

5555
// We didn't have the easy way out. Consider the most significant bit.
5656
bool negative = (header & (1 << 7)) != 0;
57-
int largestIndex = BitOperations.TrailingZeroCount(negative ? (byte)(header & ~(1 << 7)) : header);
57+
int largestIndex = BitOperations.Log2((byte)(header & 0b01111111));
58+
59+
//BitOperations.TrailingZeroCount(negative ? (byte)(header & ~(1 << 7)) : header);
5860
Span<float> components = stackalloc float[4];
5961

6062
for (int i = 0; i < components.Length; i++)

Source/Data/Resolvers/VectorResolverBase.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -131,10 +131,10 @@ public bool Write(ref BytePayloadWriter writer, TNative input, bool absolute = t
131131
{
132132
byte header = 0;
133133

134-
Span<float> floats = stackalloc float[NumComponents];
135-
CopyTo(in input, floats);
134+
Span<float> values = stackalloc float[NumComponents];
135+
CopyTo(in input, values);
136136

137-
bool isUniform = FastMath.AllComponentsEqual(floats);
137+
bool isUniform = FastMath.AllComponentsEqual(values);
138138

139139
if (input.Equals(Default) ||
140140
input.Equals(UnitX) ||
@@ -172,7 +172,7 @@ public bool Write(ref BytePayloadWriter writer, TNative input, bool absolute = t
172172
return true;
173173
}
174174

175-
HeaderData data = _Internal_CreateHeaderWithType(ref floats, true, absolute);
175+
HeaderData data = _Internal_CreateHeaderWithType(ref values, true, absolute);
176176
bool written = true;
177177

178178
header = data.Header;
@@ -185,7 +185,7 @@ public bool Write(ref BytePayloadWriter writer, TNative input, bool absolute = t
185185
for (int i = 0; i < NumComponents; i++)
186186
{
187187
// State which components are being sent
188-
if (floats[i] != 0)
188+
if (values[i] != 0)
189189
components |= (byte)(1 << i);
190190
}
191191

@@ -197,7 +197,7 @@ public bool Write(ref BytePayloadWriter writer, TNative input, bool absolute = t
197197

198198
for (int i = 0; i < NumComponents; i++)
199199
{
200-
int value = FastMath.QuantizeToInt(floats[i], 4);
200+
int value = FastMath.QuantizeToInt(values[i], 4);
201201

202202
if (!absolute && value == 0)
203203
continue;

0 commit comments

Comments
 (0)