@@ -5164,16 +5164,10 @@ FModel * SetGetBoneShared(AActor * self, int model_index)
5164
5164
}
5165
5165
}
5166
5166
5167
- FModel * SetBoneShared (AActor * self, int model_index, int &bone_index, FName * bone_name, int mode, double &interpolation_duration)
5167
+ template <bool isSet>
5168
+ FModel * SetGetBoneOffsetShared (AActor * self, int model_index, int &bone_index, FName * bone_name)
5168
5169
{
5169
- FModel * mdl = SetGetBoneShared<true , false >(self, model_index);
5170
-
5171
- if (interpolation_duration < 0 ) interpolation_duration = 0 ;
5172
-
5173
- if (mode < 0 || mode > 2 )
5174
- {
5175
- ThrowAbortException (X_OTHER, " Invalid mode for setbone" );
5176
- }
5170
+ FModel * mdl = SetGetBoneShared<isSet, true >(self, model_index);
5177
5171
5178
5172
if (bone_name)
5179
5173
{
@@ -5196,6 +5190,23 @@ FModel * SetBoneShared(AActor * self, int model_index, int &bone_index, FName *
5196
5190
return mdl;
5197
5191
}
5198
5192
5193
+ FModel * SetBoneOffsetShared (AActor * self, int model_index, int &bone_index, FName * bone_name, int mode, double &interpolation_duration)
5194
+ {
5195
+ if (interpolation_duration < 0 ) interpolation_duration = 0 ;
5196
+
5197
+ if (mode < 0 || mode > 2 )
5198
+ {
5199
+ ThrowAbortException (X_OTHER, " Invalid mode for setbone" );
5200
+ }
5201
+
5202
+ return SetGetBoneOffsetShared<true >(self, model_index, bone_index, bone_name);
5203
+ }
5204
+
5205
+ FModel * GetBoneOffsetShared (AActor * self, int model_index, int &bone_index, FName * bone_name)
5206
+ {
5207
+ return SetGetBoneOffsetShared<false >(self, model_index, bone_index, bone_name);
5208
+ }
5209
+
5199
5210
// ================================================
5200
5211
//
5201
5212
// SetBoneRotation
@@ -5204,7 +5215,7 @@ FModel * SetBoneShared(AActor * self, int model_index, int &bone_index, FName *
5204
5215
5205
5216
static void SetModelBoneRotationNative (AActor * self, int model_index, int bone_index, double rot_x, double rot_y, double rot_z, double rot_w, int mode, double interpolation_duration, double ticFrac)
5206
5217
{
5207
- FModel * mdl = SetBoneShared (self, model_index, bone_index, nullptr , mode, interpolation_duration);
5218
+ FModel * mdl = SetBoneOffsetShared (self, model_index, bone_index, nullptr , mode, interpolation_duration);
5208
5219
5209
5220
if (!mdl) return ;
5210
5221
@@ -5222,7 +5233,7 @@ static void SetModelNamedBoneRotationNative(AActor * self, int model_index, int
5222
5233
5223
5234
int bone_index;
5224
5235
5225
- FModel * mdl = SetBoneShared (self, 0 , bone_index, &bone_name, mode, interpolation_duration);
5236
+ FModel * mdl = SetBoneOffsetShared (self, model_index , bone_index, &bone_name, mode, interpolation_duration);
5226
5237
5227
5238
if (!mdl) return ;
5228
5239
@@ -5274,7 +5285,7 @@ DEFINE_ACTION_FUNCTION_NATIVE(AActor, SetNamedBoneRotation, SetNamedBoneRotation
5274
5285
5275
5286
static void SetModelBoneTranslationNative (AActor * self, int model_index, int bone_index, double rot_x, double rot_y, double rot_z, int mode, double interpolation_duration, double ticFrac)
5276
5287
{
5277
- FModel * mdl = SetBoneShared (self, model_index, bone_index, nullptr , mode, interpolation_duration);
5288
+ FModel * mdl = SetBoneOffsetShared (self, model_index, bone_index, nullptr , mode, interpolation_duration);
5278
5289
5279
5290
if (!mdl) return ;
5280
5291
@@ -5292,7 +5303,7 @@ static void SetModelNamedBoneTranslationNative(AActor * self, int model_index, i
5292
5303
5293
5304
int bone_index;
5294
5305
5295
- FModel * mdl = SetBoneShared (self, 0 , bone_index, &bone_name, mode, interpolation_duration);
5306
+ FModel * mdl = SetBoneOffsetShared (self, model_index , bone_index, &bone_name, mode, interpolation_duration);
5296
5307
5297
5308
if (!mdl) return ;
5298
5309
@@ -5342,7 +5353,7 @@ DEFINE_ACTION_FUNCTION_NATIVE(AActor, SetNamedBoneTranslation, SetNamedBoneTrans
5342
5353
5343
5354
static void SetModelBoneScalingNative (AActor * self, int model_index, int bone_index, double rot_x, double rot_y, double rot_z, int mode, double interpolation_duration, double ticFrac)
5344
5355
{
5345
- FModel * mdl = SetBoneShared (self, model_index, bone_index, nullptr , mode, interpolation_duration);
5356
+ FModel * mdl = SetBoneOffsetShared (self, model_index, bone_index, nullptr , mode, interpolation_duration);
5346
5357
5347
5358
if (!mdl) return ;
5348
5359
@@ -5360,7 +5371,7 @@ static void SetModelNamedBoneScalingNative(AActor * self, int model_index, int b
5360
5371
5361
5372
int bone_index;
5362
5373
5363
- FModel * mdl = SetBoneShared (self, 0 , bone_index, &bone_name, mode, interpolation_duration);
5374
+ FModel * mdl = SetBoneOffsetShared (self, model_index , bone_index, &bone_name, mode, interpolation_duration);
5364
5375
5365
5376
if (!mdl) return ;
5366
5377
@@ -5403,6 +5414,93 @@ DEFINE_ACTION_FUNCTION_NATIVE(AActor, SetNamedBoneScaling, SetNamedBoneScalingNa
5403
5414
}
5404
5415
5405
5416
5417
+ // ================================================
5418
+ //
5419
+ // GetBoneOffset
5420
+ //
5421
+ // ================================================
5422
+
5423
+ DEFINE_ACTION_FUNCTION_NATIVE (AActor, GetBoneOffset)
5424
+ {
5425
+ PARAM_SELF_PROLOGUE (AActor);
5426
+ PARAM_INT (bone_index);
5427
+
5428
+ FModel * mdl = GetBoneOffsetShared (self, 0 , bone_index, nullptr );
5429
+
5430
+ DVector3 translation (0 ,0 ,0 );
5431
+ DVector4 rotation (0 ,0 ,0 ,1 );
5432
+ DVector3 scaling (0 ,0 ,0 );
5433
+
5434
+ if (mdl)
5435
+ {
5436
+ auto &mod = self->modelData ->modelBoneOverrides [0 ][bone_index];
5437
+
5438
+ translation = DVector3 (mod.translation .Get (FVector3 (0 ,0 ,0 ), self->Level ->totaltime + 1.0 ));
5439
+ rotation = DVector4 (mod.rotation .Get (FQuaternion (0 ,0 ,0 ,1 ), self->Level ->totaltime + 1.0 ));
5440
+ scaling = DVector3 (mod.scaling .Get (FVector3 (0 ,0 ,0 ), self->Level ->totaltime + 1.0 ));
5441
+ }
5442
+
5443
+ if (numret > 2 )
5444
+ {
5445
+ ret[2 ].SetVector (scaling);
5446
+ numret = 3 ;
5447
+ }
5448
+
5449
+ if (numret > 1 )
5450
+ {
5451
+ ret[1 ].SetVector (translation);
5452
+ }
5453
+
5454
+ if (numret > 0 )
5455
+ {
5456
+ ret[0 ].SetVector4 (rotation);
5457
+ }
5458
+
5459
+ return numret;
5460
+ }
5461
+
5462
+ DEFINE_ACTION_FUNCTION_NATIVE (AActor, GetNamedBoneOffset)
5463
+ {
5464
+ PARAM_SELF_PROLOGUE (AActor);
5465
+ PARAM_NAME (bone_name);
5466
+
5467
+ int bone_index;
5468
+
5469
+ FModel * mdl = GetBoneOffsetShared (self, 0 , bone_index, &bone_name);
5470
+
5471
+ DVector3 translation (0 ,0 ,0 );
5472
+ DVector4 rotation (0 ,0 ,0 ,1 );
5473
+ DVector3 scaling (0 ,0 ,0 );
5474
+
5475
+ if (mdl)
5476
+ {
5477
+ auto &mod = self->modelData ->modelBoneOverrides [0 ][bone_index];
5478
+
5479
+ translation = DVector3 (mod.translation .Get (FVector3 (0 ,0 ,0 ), self->Level ->totaltime + 1.0 ));
5480
+ rotation = DVector4 (mod.rotation .Get (FQuaternion (0 ,0 ,0 ,1 ), self->Level ->totaltime + 1.0 ));
5481
+ scaling = DVector3 (mod.scaling .Get (FVector3 (0 ,0 ,0 ), self->Level ->totaltime + 1.0 ));
5482
+ }
5483
+
5484
+ if (numret > 2 )
5485
+ {
5486
+ ret[2 ].SetVector (scaling);
5487
+ numret = 3 ;
5488
+ }
5489
+
5490
+ if (numret > 1 )
5491
+ {
5492
+ ret[1 ].SetVector (translation);
5493
+ }
5494
+
5495
+ if (numret > 0 )
5496
+ {
5497
+ ret[0 ].SetVector4 (rotation);
5498
+ }
5499
+
5500
+ return numret;
5501
+ }
5502
+
5503
+
5406
5504
// ================================================
5407
5505
// SetAnimation
5408
5506
// ================================================
0 commit comments