@@ -872,7 +872,9 @@ public void ResetActionState(int actionIndex, InputActionPhase toPhase = InputAc
872
872
// Wipe state.
873
873
actionState ->phase = toPhase ;
874
874
actionState ->controlIndex = kInvalidIndex ;
875
- actionState ->bindingIndex = memory . actionBindingIndices [ memory . actionBindingIndicesAndCounts [ actionIndex ] ] ;
875
+ var idx = memory . actionBindingIndicesAndCounts [ actionIndex ] ;
876
+ var bindingCount = memory . actionBindingIndicesAndCounts [ actionIndex ] + 1 ;
877
+ actionState ->bindingIndex = memory . actionBindingIndices != null ? memory . actionBindingIndices [ idx ] : 0 ;
876
878
actionState ->interactionIndex = kInvalidIndex ;
877
879
actionState ->startTime = 0 ;
878
880
actionState ->time = 0 ;
@@ -2879,6 +2881,9 @@ internal TValue ReadValue<TValue>(int bindingIndex, int controlIndex, bool ignor
2879
2881
internal TValue ApplyProcessors < TValue > ( int bindingIndex , TValue value , InputControl < TValue > controlOfType = null )
2880
2882
where TValue : struct
2881
2883
{
2884
+ if ( totalBindingCount == 0 )
2885
+ return value ;
2886
+
2882
2887
var processorCount = bindingStates [ bindingIndex ] . processorCount ;
2883
2888
if ( processorCount > 0 )
2884
2889
{
@@ -4139,6 +4144,19 @@ public struct UnmanagedMemory : IDisposable
4139
4144
4140
4145
public ActionMapIndices * mapIndices ;
4141
4146
4147
+ // This is Anthony's version of block allocation from a blob
4148
+ private byte * AllocFromBlob ( ref byte * top , int size )
4149
+ {
4150
+ if ( size == 0 )
4151
+ return null ;
4152
+
4153
+ var allocation = top ;
4154
+
4155
+ top += size ;
4156
+
4157
+ return allocation ;
4158
+ }
4159
+
4142
4160
public void Allocate ( int mapCount , int actionCount , int bindingCount , int controlCount , int interactionCount , int compositeCount )
4143
4161
{
4144
4162
Debug . Assert ( basePtr == null , "Memory already allocated! Free first!" ) ;
@@ -4164,17 +4182,17 @@ public void Allocate(int mapCount, int actionCount, int bindingCount, int contro
4164
4182
// NOTE: This depends on the individual structs being sufficiently aligned in order to not
4165
4183
// cause any misalignment here. TriggerState, InteractionState, and BindingState all
4166
4184
// contain doubles so put them first in memory to make sure they get proper alignment.
4167
- actionStates = ( TriggerState * ) ptr ; ptr += actionCount * sizeof ( TriggerState ) ;
4168
- interactionStates = ( InteractionState * ) ptr ; ptr += interactionCount * sizeof ( InteractionState ) ;
4169
- bindingStates = ( BindingState * ) ptr ; ptr += bindingCount * sizeof ( BindingState ) ;
4170
- mapIndices = ( ActionMapIndices * ) ptr ; ptr += mapCount * sizeof ( ActionMapIndices ) ;
4171
- controlMagnitudes = ( float * ) ptr ; ptr += controlCount * sizeof ( float ) ;
4172
- compositeMagnitudes = ( float * ) ptr ; ptr += compositeCount * sizeof ( float ) ;
4173
- controlIndexToBindingIndex = ( int * ) ptr ; ptr += controlCount * sizeof ( int ) ;
4174
- controlGroupingAndComplexity = ( ushort * ) ptr ; ptr += controlCount * sizeof ( ushort ) * 2 ;
4175
- actionBindingIndicesAndCounts = ( ushort * ) ptr ; ptr += actionCount * sizeof ( ushort ) * 2 ;
4176
- actionBindingIndices = ( ushort * ) ptr ; ptr += bindingCount * sizeof ( ushort ) ;
4177
- enabledControls = ( int * ) ptr ; ptr += ( controlCount + 31 ) / 32 * sizeof ( int ) ;
4185
+ actionStates = ( TriggerState * ) AllocFromBlob ( ref ptr , actionCount * sizeof ( TriggerState ) ) ;
4186
+ interactionStates = ( InteractionState * ) AllocFromBlob ( ref ptr , interactionCount * sizeof ( InteractionState ) ) ;
4187
+ bindingStates = ( BindingState * ) AllocFromBlob ( ref ptr , bindingCount * sizeof ( BindingState ) ) ;
4188
+ mapIndices = ( ActionMapIndices * ) AllocFromBlob ( ref ptr , mapCount * sizeof ( ActionMapIndices ) ) ;
4189
+ controlMagnitudes = ( float * ) AllocFromBlob ( ref ptr , controlCount * sizeof ( float ) ) ;
4190
+ compositeMagnitudes = ( float * ) AllocFromBlob ( ref ptr , compositeCount * sizeof ( float ) ) ;
4191
+ controlIndexToBindingIndex = ( int * ) AllocFromBlob ( ref ptr , controlCount * sizeof ( int ) ) ;
4192
+ controlGroupingAndComplexity = ( ushort * ) AllocFromBlob ( ref ptr , controlCount * sizeof ( ushort ) * 2 ) ;
4193
+ actionBindingIndicesAndCounts = ( ushort * ) AllocFromBlob ( ref ptr , actionCount * sizeof ( ushort ) * 2 ) ;
4194
+ actionBindingIndices = ( ushort * ) AllocFromBlob ( ref ptr , bindingCount * sizeof ( ushort ) ) ;
4195
+ enabledControls = ( int * ) AllocFromBlob ( ref ptr , ( controlCount + 31 ) / 32 * sizeof ( int ) ) ;
4178
4196
}
4179
4197
4180
4198
public void Dispose ( )
0 commit comments