/
Dynamics.bindings.cs
1655 lines (1371 loc) · 81.2 KB
/
Dynamics.bindings.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// Unity C# reference source
// Copyright (c) Unity Technologies. For terms of use, see
// https://unity3d.com/legal/licenses/Unity_Reference_Only_License
using System;
using UnityEngine.Bindings;
using UnityEngine.Scripting;
using System.Runtime.InteropServices;
using UnityEngine.Internal;
namespace UnityEngine
{
[NativeHeader("Runtime/Dynamics/PhysicMaterial.h")]
public class PhysicMaterial : UnityEngine.Object
{
public PhysicMaterial() { Internal_CreateDynamicsMaterial(this, "DynamicMaterial"); }
public PhysicMaterial(string name) { Internal_CreateDynamicsMaterial(this, name); }
extern private static void Internal_CreateDynamicsMaterial([Writable] PhysicMaterial mat, string name);
extern public float bounciness { get; set; }
extern public float dynamicFriction { get; set; }
extern public float staticFriction { get; set; }
extern public PhysicMaterialCombine frictionCombine { get; set; }
extern public PhysicMaterialCombine bounceCombine { get; set; }
[Obsolete("Use PhysicMaterial.bounciness instead (UnityUpgradable) -> bounciness")]
public float bouncyness { get { return bounciness; } set { bounciness = value; } }
[Obsolete("Anisotropic friction is no longer supported since Unity 5.0.", true)]
public Vector3 frictionDirection2 { get { return Vector3.zero; } set {} }
[Obsolete("Anisotropic friction is no longer supported since Unity 5.0.", true)]
public float dynamicFriction2 { get { return 0; } set {} }
[Obsolete("Anisotropic friction is no longer supported since Unity 5.0.", true)]
public float staticFriction2 { get { return 0; } set {} }
[Obsolete("Anisotropic friction is no longer supported since Unity 5.0.", true)]
public Vector3 frictionDirection { get { return Vector3.zero; } set {} }
}
[NativeHeader("Runtime/Interfaces/IRaycast.h")]
[NativeHeader("PhysicsScriptingClasses.h")]
[NativeHeader("Runtime/Dynamics/RaycastHit.h")]
[UsedByNativeCode]
public struct RaycastHit
{
[NativeName("point")] internal Vector3 m_Point;
[NativeName("normal")] internal Vector3 m_Normal;
[NativeName("faceID")] internal uint m_FaceID;
[NativeName("distance")] internal float m_Distance;
[NativeName("uv")] internal Vector2 m_UV;
[NativeName("collider")] internal int m_Collider;
public Collider collider { get { return Object.FindObjectFromInstanceID(m_Collider) as Collider; } }
public Vector3 point { get { return m_Point; } set { m_Point = value; } }
public Vector3 normal { get { return m_Normal; } set { m_Normal = value; } }
public Vector3 barycentricCoordinate { get { return new Vector3(1.0F - (m_UV.y + m_UV.x), m_UV.x, m_UV.y); } set { m_UV = value; } }
public float distance { get { return m_Distance; } set { m_Distance = value; } }
public int triangleIndex { get { return (int)m_FaceID; } }
[FreeFunction] extern static private Vector2 CalculateRaycastTexCoord(Collider collider, Vector2 uv, Vector3 pos, uint face, int textcoord);
public Vector2 textureCoord { get { return CalculateRaycastTexCoord(collider, m_UV, m_Point, m_FaceID, 0); } }
public Vector2 textureCoord2 { get { return CalculateRaycastTexCoord(collider, m_UV, m_Point, m_FaceID, 1); } }
[Obsolete("Use textureCoord2 instead. (UnityUpgradable) -> textureCoord2")]
public Vector2 textureCoord1 { get { return textureCoord2; } }
public Transform transform
{
get
{
Rigidbody body = rigidbody;
if (body != null)
return body.transform;
else if (collider != null)
return collider.transform;
else
return null;
}
}
public Rigidbody rigidbody { get { return collider != null ? collider.attachedRigidbody : null; } }
public Vector2 lightmapCoord
{
get
{
Vector2 coord = CalculateRaycastTexCoord(collider, m_UV, m_Point, m_FaceID, 1);
if (collider.GetComponent<Renderer>() != null)
{
Vector4 st = collider.GetComponent<Renderer>().lightmapScaleOffset;
coord.x = coord.x * st.x + st.z;
coord.y = coord.y * st.y + st.w;
}
return coord;
}
}
}
[RequireComponent(typeof(Transform))]
[NativeHeader("Runtime/Dynamics/Rigidbody.h")]
public class Rigidbody : UnityEngine.Component
{
extern public Vector3 velocity { get; set; }
extern public Vector3 angularVelocity { get; set; }
extern public float drag { get; set; }
extern public float angularDrag { get; set; }
extern public float mass { get; set; }
extern public void SetDensity(float density);
extern public bool useGravity { get; set; }
extern public float maxDepenetrationVelocity { get; set; }
extern public bool isKinematic { get; set; }
extern public bool freezeRotation { get; set; }
extern public RigidbodyConstraints constraints { get; set; }
extern public CollisionDetectionMode collisionDetectionMode { get; set; }
extern public Vector3 centerOfMass { get; set; }
extern public Vector3 worldCenterOfMass { get; }
extern public Quaternion inertiaTensorRotation { get; set; }
extern public Vector3 inertiaTensor { get; set; }
extern public bool detectCollisions { get; set; }
extern public Vector3 position { get; set; }
extern public Quaternion rotation { get; set; }
extern public RigidbodyInterpolation interpolation { get; set; }
extern public int solverIterations { get; set; }
extern public float sleepThreshold { get; set; }
extern public float maxAngularVelocity { get; set; }
extern public void MovePosition(Vector3 position);
extern public void MoveRotation(Quaternion rot);
extern public void Sleep();
extern public bool IsSleeping();
extern public void WakeUp();
extern public void ResetCenterOfMass();
extern public void ResetInertiaTensor();
extern public Vector3 GetRelativePointVelocity(Vector3 relativePoint);
extern public Vector3 GetPointVelocity(Vector3 worldPoint);
extern public int solverVelocityIterations { get; set; }
[Obsolete("The sleepVelocity is no longer supported. Use sleepThreshold. Note that sleepThreshold is energy but not velocity.")]
extern public float sleepVelocity { get; set; }
[Obsolete("The sleepAngularVelocity is no longer supported. Set Use sleepThreshold to specify energy.")]
extern public float sleepAngularVelocity { get; set; }
[Obsolete("Use Rigidbody.maxAngularVelocity instead.")]
public void SetMaxAngularVelocity(float a) { maxAngularVelocity = a; }
[Obsolete("Cone friction is no longer supported.")]
public bool useConeFriction { get { return false; } set {} }
[Obsolete("Please use Rigidbody.solverIterations instead. (UnityUpgradable) -> solverIterations")]
public int solverIterationCount { get { return solverIterations; } set { solverIterations = value; } }
[Obsolete("Please use Rigidbody.solverVelocityIterations instead. (UnityUpgradable) -> solverVelocityIterations")]
public int solverVelocityIterationCount { get { return solverVelocityIterations; } set { solverVelocityIterations = value; } }
extern public void AddForce(Vector3 force, [DefaultValue("ForceMode.Force")] ForceMode mode);
[ExcludeFromDocs]
public void AddForce(Vector3 force)
{
AddForce(force, ForceMode.Force);
}
public void AddForce(float x, float y, float z, [DefaultValue("ForceMode.Force")] ForceMode mode) { AddForce(new Vector3(x, y, z), mode); }
[ExcludeFromDocs]
public void AddForce(float x, float y, float z)
{
AddForce(new Vector3(x, y, z), ForceMode.Force);
}
extern public void AddRelativeForce(Vector3 force, [DefaultValue("ForceMode.Force")] ForceMode mode);
[ExcludeFromDocs]
public void AddRelativeForce(Vector3 force)
{
AddRelativeForce(force, ForceMode.Force);
}
public void AddRelativeForce(float x, float y, float z, [DefaultValue("ForceMode.Force")] ForceMode mode) { AddRelativeForce(new Vector3(x, y, z), mode); }
[ExcludeFromDocs]
public void AddRelativeForce(float x, float y, float z)
{
AddRelativeForce(new Vector3(x, y, z), ForceMode.Force);
}
extern public void AddTorque(Vector3 torque, [DefaultValue("ForceMode.Force")] ForceMode mode);
[ExcludeFromDocs]
public void AddTorque(Vector3 torque)
{
AddTorque(torque, ForceMode.Force);
}
public void AddTorque(float x, float y, float z, [DefaultValue("ForceMode.Force")] ForceMode mode) { AddTorque(new Vector3(x, y, z), mode); }
[ExcludeFromDocs]
public void AddTorque(float x, float y, float z)
{
AddTorque(new Vector3(x, y, z), ForceMode.Force);
}
extern public void AddRelativeTorque(Vector3 torque, [DefaultValue("ForceMode.Force")] ForceMode mode);
[ExcludeFromDocs]
public void AddRelativeTorque(Vector3 torque)
{
AddRelativeTorque(torque, ForceMode.Force);
}
public void AddRelativeTorque(float x, float y, float z, [DefaultValue("ForceMode.Force")] ForceMode mode) { AddRelativeTorque(new Vector3(x, y, z), mode); }
[ExcludeFromDocs]
public void AddRelativeTorque(float x, float y, float z)
{
AddRelativeTorque(x, y, z, ForceMode.Force);
}
extern public void AddForceAtPosition(Vector3 force, Vector3 position, [DefaultValue("ForceMode.Force")] ForceMode mode);
[ExcludeFromDocs]
public void AddForceAtPosition(Vector3 force, Vector3 position)
{
AddForceAtPosition(force, position, ForceMode.Force);
}
extern public void AddExplosionForce(float explosionForce, Vector3 explosionPosition, float explosionRadius, [DefaultValue("0.0f")] float upwardsModifier, [DefaultValue("ForceMode.Force)")] ForceMode mode);
[ExcludeFromDocs]
public void AddExplosionForce(float explosionForce, Vector3 explosionPosition, float explosionRadius, float upwardsModifier)
{
AddExplosionForce(explosionForce, explosionPosition, explosionRadius, upwardsModifier, ForceMode.Force);
}
[ExcludeFromDocs]
public void AddExplosionForce(float explosionForce, Vector3 explosionPosition, float explosionRadius)
{
AddExplosionForce(explosionForce, explosionPosition, explosionRadius, 0.0f, ForceMode.Force);
}
[NativeName("ClosestPointOnBounds")]
extern private void Internal_ClosestPointOnBounds(Vector3 point, ref Vector3 outPos, ref float distance);
public Vector3 ClosestPointOnBounds(Vector3 position)
{
float dist = 0f;
Vector3 outpos = Vector3.zero;
Internal_ClosestPointOnBounds(position, ref outpos, ref dist);
return outpos;
}
extern private RaycastHit SweepTest(Vector3 direction, float maxDistance, QueryTriggerInteraction queryTriggerInteraction, ref bool hasHit);
public bool SweepTest(Vector3 direction, out RaycastHit hitInfo, [DefaultValue("Mathf.Infinity")] float maxDistance, [DefaultValue("QueryTriggerInteraction.UseGlobal")] QueryTriggerInteraction queryTriggerInteraction)
{
float dirLength = direction.magnitude;
if (dirLength > float.Epsilon)
{
Vector3 normalizedDirection = direction / dirLength;
bool hasHit = false;
hitInfo = SweepTest(normalizedDirection, maxDistance, queryTriggerInteraction, ref hasHit);
return hasHit;
}
else
{
hitInfo = new RaycastHit();
return false;
}
}
[ExcludeFromDocs]
public bool SweepTest(Vector3 direction, out RaycastHit hitInfo, float maxDistance)
{
return SweepTest(direction, out hitInfo, maxDistance, QueryTriggerInteraction.UseGlobal);
}
[ExcludeFromDocs]
public bool SweepTest(Vector3 direction, out RaycastHit hitInfo)
{
return SweepTest(direction, out hitInfo, Mathf.Infinity, QueryTriggerInteraction.UseGlobal);
}
[NativeName("SweepTestAll")]
extern private RaycastHit[] Internal_SweepTestAll(Vector3 direction, float maxDistance, QueryTriggerInteraction queryTriggerInteraction);
public RaycastHit[] SweepTestAll(Vector3 direction, [DefaultValue("Mathf.Infinity")] float maxDistance, [DefaultValue("QueryTriggerInteraction.UseGlobal")] QueryTriggerInteraction queryTriggerInteraction)
{
float dirLength = direction.magnitude;
if (dirLength > float.Epsilon)
{
Vector3 normalizedDirection = direction / dirLength;
return Internal_SweepTestAll(normalizedDirection, maxDistance, queryTriggerInteraction);
}
else
{
return new RaycastHit[0];
}
}
[ExcludeFromDocs]
public RaycastHit[] SweepTestAll(Vector3 direction, float maxDistance)
{
return SweepTestAll(direction, maxDistance, QueryTriggerInteraction.UseGlobal);
}
[ExcludeFromDocs]
public RaycastHit[] SweepTestAll(Vector3 direction)
{
return SweepTestAll(direction, Mathf.Infinity, QueryTriggerInteraction.UseGlobal);
}
}
[RequiredByNativeCode]
[RequireComponent(typeof(Transform))]
[NativeHeader("Runtime/Dynamics/Collider.h")]
public partial class Collider : Component
{
extern public bool enabled { get; set; }
extern public Rigidbody attachedRigidbody {[NativeMethod("GetRigidbody")] get; }
extern public bool isTrigger { get; set; }
extern public float contactOffset { get; set; }
extern public Vector3 ClosestPoint(Vector3 position);
extern public Bounds bounds { get; }
[NativeMethod("Material")]
extern public PhysicMaterial sharedMaterial { get; set; }
extern public PhysicMaterial material
{
[NativeMethod("GetClonedMaterial")] get;
[NativeMethod("SetMaterial")] set;
}
extern private RaycastHit Raycast(Ray ray, float maxDistance, ref bool hasHit);
public bool Raycast(Ray ray, out RaycastHit hitInfo, float maxDistance)
{
bool hasHit = false;
hitInfo = Raycast(ray, maxDistance, ref hasHit);
return hasHit;
}
[NativeName("ClosestPointOnBounds")]
extern private void Internal_ClosestPointOnBounds(Vector3 point, ref Vector3 outPos, ref float distance);
public Vector3 ClosestPointOnBounds(Vector3 position)
{
float dist = 0f;
Vector3 outpos = Vector3.zero;
Internal_ClosestPointOnBounds(position, ref outpos, ref dist);
return outpos;
}
}
[NativeHeader("Runtime/Dynamics/CharacterController.h")]
public class CharacterController : Collider
{
extern public bool SimpleMove(Vector3 speed);
extern public CollisionFlags Move(Vector3 motion);
extern public Vector3 velocity { get; }
extern public bool isGrounded {[NativeName("IsGrounded")] get; }
extern public CollisionFlags collisionFlags { get; }
extern public float radius { get; set; }
extern public float height { get; set; }
extern public Vector3 center { get; set; }
extern public float slopeLimit { get; set; }
extern public float stepOffset { get; set; }
extern public float skinWidth { get; set; }
extern public float minMoveDistance { get; set; }
extern public bool detectCollisions { get; set; }
extern public bool enableOverlapRecovery { get; set; }
}
[RequiredByNativeCode]
[NativeHeader("Runtime/Dynamics/MeshCollider.h")]
[NativeHeader("Runtime/Graphics/Mesh/Mesh.h")]
public class MeshCollider : Collider
{
extern public Mesh sharedMesh { get; set; }
extern public bool convex { get; set; }
public bool inflateMesh
{
get
{
return (cookingOptions & MeshColliderCookingOptions.InflateConvexMesh) != 0;
}
set
{
MeshColliderCookingOptions newOptions = cookingOptions & ~MeshColliderCookingOptions.InflateConvexMesh;
if (value)
newOptions |= MeshColliderCookingOptions.InflateConvexMesh;
cookingOptions = newOptions;
}
}
extern public MeshColliderCookingOptions cookingOptions { get; set; }
extern public float skinWidth { get; set; }
[Obsolete("Configuring smooth sphere collisions is no longer needed.")]
public bool smoothSphereCollisions { get { return true; } set {} }
}
[RequiredByNativeCode]
[NativeHeader("Runtime/Dynamics/CapsuleCollider.h")]
public class CapsuleCollider : Collider
{
extern public Vector3 center { get; set; }
extern public float radius { get; set; }
extern public float height { get; set; }
extern public int direction { get; set; }
extern internal Vector2 GetGlobalExtents();
extern internal Matrix4x4 CalculateTransform();
}
[RequiredByNativeCode]
[NativeHeader("Runtime/Dynamics/BoxCollider.h")]
public class BoxCollider : Collider
{
extern public Vector3 center { get; set; }
extern public Vector3 size { get; set; }
[Obsolete("Use BoxCollider.size instead.")]
public Vector3 extents { get { return size * 0.5F; } set { size = value * 2.0F; } }
}
[RequiredByNativeCode]
[NativeHeader("Runtime/Dynamics/SphereCollider.h")]
public class SphereCollider : Collider
{
extern public Vector3 center { get; set; }
extern public float radius { get; set; }
}
[RequireComponent(typeof(Rigidbody))]
[NativeHeader("Runtime/Dynamics/ConstantForce.h")]
public class ConstantForce : Behaviour
{
extern public Vector3 force { get; set; }
extern public Vector3 relativeForce { get; set; }
extern public Vector3 torque { get; set; }
extern public Vector3 relativeTorque { get; set; }
}
[RequireComponent(typeof(Rigidbody))]
[NativeHeader("Runtime/Dynamics/Joint.h")]
[NativeClass("Unity::Joint")]
public class Joint : UnityEngine.Component
{
extern public Rigidbody connectedBody { get; set; }
extern public Vector3 axis { get; set; }
extern public Vector3 anchor { get; set; }
extern public Vector3 connectedAnchor { get; set; }
extern public bool autoConfigureConnectedAnchor { get; set; }
extern public float breakForce { get; set; }
extern public float breakTorque { get; set; }
extern public bool enableCollision { get; set; }
extern public bool enablePreprocessing { get; set; }
extern public float massScale { get; set; }
extern public float connectedMassScale { get; set; }
extern private void GetCurrentForces(ref Vector3 linearForce, ref Vector3 angularForce);
public Vector3 currentForce
{
get
{
Vector3 force = Vector3.zero;
Vector3 torque = Vector3.zero;
GetCurrentForces(ref force, ref torque);
return force;
}
}
public Vector3 currentTorque
{
get
{
Vector3 force = Vector3.zero;
Vector3 torque = Vector3.zero;
GetCurrentForces(ref force, ref torque);
return torque;
}
}
extern internal Matrix4x4 GetLocalPoseMatrix(int bodyIndex);
}
[NativeHeader("Runtime/Dynamics/HingeJoint.h")]
[NativeClass("Unity::HingeJoint")]
public class HingeJoint : Joint
{
extern public JointMotor motor { get; set; }
extern public JointLimits limits { get; set; }
extern public JointSpring spring { get; set; }
extern public bool useMotor { get; set; }
extern public bool useLimits { get; set; }
extern public bool useSpring { get; set; }
extern public float velocity { get; }
extern public float angle { get; }
}
[NativeHeader("Runtime/Dynamics/SpringJoint.h")]
[NativeClass("Unity::SpringJoint")]
public class SpringJoint : Joint
{
extern public float spring { get; set; }
extern public float damper { get; set; }
extern public float minDistance { get; set; }
extern public float maxDistance { get; set; }
extern public float tolerance { get; set; }
}
[NativeHeader("Runtime/Dynamics/FixedJoint.h")]
[NativeClass("Unity::FixedJoint")]
public class FixedJoint : Joint
{
}
[NativeHeader("Runtime/Dynamics/CharacterJoint.h")]
[NativeClass("Unity::CharacterJoint")]
public class CharacterJoint : Joint
{
extern public Vector3 swingAxis { get; set; }
extern public SoftJointLimitSpring twistLimitSpring { get; set; }
extern public SoftJointLimitSpring swingLimitSpring { get; set; }
extern public SoftJointLimit lowTwistLimit { get; set; }
extern public SoftJointLimit highTwistLimit { get; set; }
extern public SoftJointLimit swing1Limit { get; set; }
extern public SoftJointLimit swing2Limit { get; set; }
extern public bool enableProjection { get; set; }
extern public float projectionDistance { get; set; }
extern public float projectionAngle { get; set; }
[Obsolete("TargetRotation not in use for Unity 5 and assumed disabled.", true)]
public Quaternion targetRotation;
[Obsolete("TargetAngularVelocity not in use for Unity 5 and assumed disabled.", true)]
public Vector3 targetAngularVelocity;
[Obsolete("RotationDrive not in use for Unity 5 and assumed disabled.")]
public JointDrive rotationDrive;
}
[NativeHeader("Runtime/Dynamics/ConfigurableJoint.h")]
[NativeClass("Unity::ConfigurableJoint")]
public class ConfigurableJoint : Joint
{
extern public Vector3 secondaryAxis { get; set; }
extern public ConfigurableJointMotion xMotion { get; set; }
extern public ConfigurableJointMotion yMotion { get; set; }
extern public ConfigurableJointMotion zMotion { get; set; }
extern public ConfigurableJointMotion angularXMotion { get; set; }
extern public ConfigurableJointMotion angularYMotion { get; set; }
extern public ConfigurableJointMotion angularZMotion { get; set; }
extern public SoftJointLimitSpring linearLimitSpring { get; set; }
extern public SoftJointLimitSpring angularXLimitSpring { get; set; }
extern public SoftJointLimitSpring angularYZLimitSpring { get; set; }
extern public SoftJointLimit linearLimit { get; set; }
extern public SoftJointLimit lowAngularXLimit { get; set; }
extern public SoftJointLimit highAngularXLimit { get; set; }
extern public SoftJointLimit angularYLimit { get; set; }
extern public SoftJointLimit angularZLimit { get; set; }
extern public Vector3 targetPosition { get; set; }
extern public Vector3 targetVelocity { get; set; }
extern public JointDrive xDrive { get; set; }
extern public JointDrive yDrive { get; set; }
extern public JointDrive zDrive { get; set; }
extern public Quaternion targetRotation { get; set; }
extern public Vector3 targetAngularVelocity { get; set; }
extern public RotationDriveMode rotationDriveMode { get; set; }
extern public JointDrive angularXDrive { get; set; }
extern public JointDrive angularYZDrive { get; set; }
extern public JointDrive slerpDrive { get; set; }
extern public JointProjectionMode projectionMode { get; set; }
extern public float projectionDistance { get; set; }
extern public float projectionAngle { get; set; }
extern public bool configuredInWorldSpace { get; set; }
extern public bool swapBodies { get; set; }
}
[UsedByNativeCode]
[NativeHeader("Runtime/Dynamics/MessageParameters.h")]
public struct ContactPoint
{
internal Vector3 m_Point;
internal Vector3 m_Normal;
internal int m_ThisColliderInstanceID;
internal int m_OtherColliderInstanceID;
internal float m_Separation;
public Vector3 point { get { return m_Point; } }
public Vector3 normal { get { return m_Normal; } }
public Collider thisCollider { get { return GetColliderByInstanceID(m_ThisColliderInstanceID); } }
public Collider otherCollider { get { return GetColliderByInstanceID(m_OtherColliderInstanceID); } }
public float separation { get { return m_Separation; }}
[FreeFunction]
extern private static Collider GetColliderByInstanceID(int instanceID);
}
[NativeHeader("Runtime/Dynamics/PhysicsManager.h")]
[StaticAccessor("GetPhysicsManager()", StaticAccessorType.Dot)]
public class Physics
{
// PX_MAX_F32_MINUS_EPS; currently used in e.g., EnforceJointLimitsConsistency()
internal const float k_MaxFloatMinusEpsilon = 340282326356119260000000000000000000000f;
public const int IgnoreRaycastLayer = 1 << 2;
public const int DefaultRaycastLayers = ~IgnoreRaycastLayer;
public const int AllLayers = ~0;
[Obsolete("Please use Physics.IgnoreRaycastLayer instead. (UnityUpgradable) -> IgnoreRaycastLayer", true)]
public const int kIgnoreRaycastLayer = IgnoreRaycastLayer;
[Obsolete("Please use Physics.DefaultRaycastLayers instead. (UnityUpgradable) -> DefaultRaycastLayers", true)]
public const int kDefaultRaycastLayers = DefaultRaycastLayers;
[Obsolete("Please use Physics.AllLayers instead. (UnityUpgradable) -> AllLayers", true)]
public const int kAllLayers = AllLayers;
[Obsolete("Use Physics.defaultContactOffset or Collider.contactOffset instead.", true)]
public static float minPenetrationForPenalty { get { return 0f; } set {} }
extern public static Vector3 gravity {[ThreadSafe] get; set; }
extern public static float defaultContactOffset { get; set; }
extern public static float sleepThreshold { get; set; }
extern public static bool queriesHitTriggers { get; set; }
extern public static bool queriesHitBackfaces { get; set; }
extern public static float bounceThreshold { get; set; }
extern public static int defaultSolverIterations { get; set; }
extern public static int defaultSolverVelocityIterations { get; set; }
[Obsolete("Please use bounceThreshold instead.")]
public static float bounceTreshold { get { return bounceThreshold; } set { bounceThreshold = value; } }
[Obsolete("The sleepVelocity is no longer supported. Use sleepThreshold. Note that sleepThreshold is energy but not velocity.")]
public static float sleepVelocity { get { return 0f; } set {} }
[Obsolete("The sleepAngularVelocity is no longer supported. Use sleepThreshold. Note that sleepThreshold is energy but not velocity.")]
public static float sleepAngularVelocity { get { return 0f; } set {} }
[Obsolete("Use Rigidbody.maxAngularVelocity instead.", true)]
public static float maxAngularVelocity { get { return 0f; } set {} }
[Obsolete("Please use Physics.defaultSolverIterations instead. (UnityUpgradable) -> defaultSolverIterations")]
public static int solverIterationCount { get { return defaultSolverIterations; } set { defaultSolverIterations = value; } }
[Obsolete("Please use Physics.defaultSolverVelocityIterations instead. (UnityUpgradable) -> defaultSolverVelocityIterations")]
public static int solverVelocityIterationCount { get { return defaultSolverVelocityIterations; } set { defaultSolverVelocityIterations = value; } }
[Obsolete("penetrationPenaltyForce has no effect.")]
public static float penetrationPenaltyForce { get { return 0f; } set {} }
extern public static void IgnoreCollision(Collider collider1, Collider collider2, [DefaultValue("true")] bool ignore);
[ExcludeFromDocs]
public static void IgnoreCollision(Collider collider1, Collider collider2)
{
IgnoreCollision(collider1, collider2, true);
}
[NativeName("IgnoreCollision")]
extern public static void IgnoreLayerCollision(int layer1, int layer2, [DefaultValue("true")] bool ignore);
[ExcludeFromDocs]
public static void IgnoreLayerCollision(int layer1, int layer2)
{
IgnoreLayerCollision(layer1, layer2, true);
}
[NativeName("GetIgnoreCollision")]
extern public static bool GetIgnoreLayerCollision(int layer1, int layer2);
[NativeName("RaycastTest")]
[StaticAccessor("GetPhysicsManager().GetPhysicsQuery()", StaticAccessorType.Dot)]
extern private static bool Query_RaycastTest(Ray ray, float maxDistance, int layerMask, QueryTriggerInteraction queryTriggerInteraction);
private static bool Internal_RaycastTest(Vector3 origin, Vector3 direction, float maxDistance, int layerMask, QueryTriggerInteraction queryTriggerInteraction)
{
float dirLength = direction.magnitude;
if (dirLength > float.Epsilon)
{
Vector3 normalizedDirection = direction / dirLength;
Ray ray = new Ray(origin, normalizedDirection);
return Query_RaycastTest(ray, maxDistance, layerMask, queryTriggerInteraction);
}
else
return false;
}
static public bool Raycast(Vector3 origin, Vector3 direction, [DefaultValue("Mathf.Infinity")] float maxDistance, [DefaultValue("DefaultRaycastLayers")] int layerMask, [DefaultValue("QueryTriggerInteraction.UseGlobal")] QueryTriggerInteraction queryTriggerInteraction)
{
return Internal_RaycastTest(origin, direction, maxDistance, layerMask, queryTriggerInteraction);
}
[ExcludeFromDocs]
static public bool Raycast(Vector3 origin, Vector3 direction, float maxDistance, int layerMask)
{
return Internal_RaycastTest(origin, direction, maxDistance, layerMask, QueryTriggerInteraction.UseGlobal);
}
[ExcludeFromDocs]
static public bool Raycast(Vector3 origin, Vector3 direction, float maxDistance)
{
return Internal_RaycastTest(origin, direction, maxDistance, DefaultRaycastLayers, QueryTriggerInteraction.UseGlobal);
}
[ExcludeFromDocs]
static public bool Raycast(Vector3 origin, Vector3 direction)
{
return Internal_RaycastTest(origin, direction, Mathf.Infinity, DefaultRaycastLayers, QueryTriggerInteraction.UseGlobal);
}
[NativeName("Raycast")]
[StaticAccessor("GetPhysicsManager().GetPhysicsQuery()", StaticAccessorType.Dot)]
extern private static bool Internal_Raycast(Ray ray, float maxDistance, ref RaycastHit hit, int layerMask, QueryTriggerInteraction queryTriggerInteraction);
public static bool Raycast(Vector3 origin, Vector3 direction, out RaycastHit hitInfo, float maxDistance, int layerMask, QueryTriggerInteraction queryTriggerInteraction)
{
hitInfo = new RaycastHit();
float dirLength = direction.magnitude;
if (dirLength > float.Epsilon)
{
Vector3 normalizedDirection = direction / dirLength;
Ray ray = new Ray(origin, normalizedDirection);
return Internal_Raycast(ray, maxDistance, ref hitInfo, layerMask, queryTriggerInteraction);
}
else
return false;
}
// This is not actually called by native code, but needs the [RequiredByNativeCode]
// attribute as it is called by reflection from GraphicsRaycaster.cs, to avoid a hard
// dependency to this module.
[RequiredByNativeCode]
[ExcludeFromDocs]
static public bool Raycast(Vector3 origin, Vector3 direction, out RaycastHit hitInfo, float maxDistance, int layerMask)
{
return Raycast(origin, direction, out hitInfo, maxDistance, layerMask, QueryTriggerInteraction.UseGlobal);
}
[ExcludeFromDocs]
static public bool Raycast(Vector3 origin, Vector3 direction, out RaycastHit hitInfo, float maxDistance)
{
return Raycast(origin, direction, out hitInfo, maxDistance, DefaultRaycastLayers, QueryTriggerInteraction.UseGlobal);
}
[ExcludeFromDocs]
static public bool Raycast(Vector3 origin, Vector3 direction, out RaycastHit hitInfo)
{
return Raycast(origin, direction, out hitInfo, Mathf.Infinity, DefaultRaycastLayers, QueryTriggerInteraction.UseGlobal);
}
static public bool Raycast(Ray ray, [DefaultValue("Mathf.Infinity")] float maxDistance, [DefaultValue("DefaultRaycastLayers")] int layerMask, [DefaultValue("QueryTriggerInteraction.UseGlobal")] QueryTriggerInteraction queryTriggerInteraction)
{
return Raycast(ray.origin, ray.direction, maxDistance, layerMask, queryTriggerInteraction);
}
[ExcludeFromDocs]
static public bool Raycast(Ray ray, float maxDistance, int layerMask)
{
return Raycast(ray.origin, ray.direction, maxDistance, layerMask, QueryTriggerInteraction.UseGlobal);
}
[ExcludeFromDocs]
static public bool Raycast(Ray ray, float maxDistance)
{
return Raycast(ray.origin, ray.direction, maxDistance, DefaultRaycastLayers, QueryTriggerInteraction.UseGlobal);
}
[ExcludeFromDocs]
static public bool Raycast(Ray ray)
{
return Raycast(ray.origin, ray.direction, Mathf.Infinity, DefaultRaycastLayers, QueryTriggerInteraction.UseGlobal);
}
static public bool Raycast(Ray ray, out RaycastHit hitInfo, [DefaultValue("Mathf.Infinity")] float maxDistance, [DefaultValue("DefaultRaycastLayers")] int layerMask, [DefaultValue("QueryTriggerInteraction.UseGlobal")] QueryTriggerInteraction queryTriggerInteraction)
{
return Raycast(ray.origin, ray.direction, out hitInfo, maxDistance, layerMask, queryTriggerInteraction);
}
[ExcludeFromDocs]
static public bool Raycast(Ray ray, out RaycastHit hitInfo, float maxDistance, int layerMask)
{
return Raycast(ray.origin, ray.direction, out hitInfo, maxDistance, layerMask, QueryTriggerInteraction.UseGlobal);
}
[ExcludeFromDocs]
static public bool Raycast(Ray ray, out RaycastHit hitInfo, float maxDistance)
{
return Raycast(ray.origin, ray.direction, out hitInfo, maxDistance, DefaultRaycastLayers, QueryTriggerInteraction.UseGlobal);
}
[ExcludeFromDocs]
static public bool Raycast(Ray ray, out RaycastHit hitInfo)
{
return Raycast(ray.origin, ray.direction, out hitInfo, Mathf.Infinity, DefaultRaycastLayers, QueryTriggerInteraction.UseGlobal);
}
static public bool Linecast(Vector3 start, Vector3 end, [DefaultValue("DefaultRaycastLayers")] int layerMask, [DefaultValue("QueryTriggerInteraction.UseGlobal")] QueryTriggerInteraction queryTriggerInteraction)
{
Vector3 dir = end - start;
return Raycast(start, dir, dir.magnitude, layerMask, queryTriggerInteraction);
}
[ExcludeFromDocs]
static public bool Linecast(Vector3 start, Vector3 end, int layerMask)
{
return Linecast(start, end, layerMask, QueryTriggerInteraction.UseGlobal);
}
[ExcludeFromDocs]
static public bool Linecast(Vector3 start, Vector3 end)
{
return Linecast(start, end, DefaultRaycastLayers, QueryTriggerInteraction.UseGlobal);
}
static public bool Linecast(Vector3 start, Vector3 end, out RaycastHit hitInfo, [DefaultValue("DefaultRaycastLayers")] int layerMask, [DefaultValue("QueryTriggerInteraction.UseGlobal")] QueryTriggerInteraction queryTriggerInteraction)
{
Vector3 dir = end - start;
return Raycast(start, dir, out hitInfo, dir.magnitude, layerMask, queryTriggerInteraction);
}
[ExcludeFromDocs]
static public bool Linecast(Vector3 start, Vector3 end, out RaycastHit hitInfo, int layerMask)
{
return Linecast(start, end, out hitInfo, layerMask, QueryTriggerInteraction.UseGlobal);
}
[ExcludeFromDocs]
static public bool Linecast(Vector3 start, Vector3 end, out RaycastHit hitInfo)
{
return Linecast(start, end, out hitInfo, DefaultRaycastLayers, QueryTriggerInteraction.UseGlobal);
}
[NativeName("CapsuleCast")]
[StaticAccessor("GetPhysicsManager().GetPhysicsQuery()", StaticAccessorType.Dot)]
extern private static bool Query_CapsuleCast(Vector3 point1, Vector3 point2, float radius, Vector3 direction, float maxDistance, ref RaycastHit hitInfo, int layerMask, QueryTriggerInteraction queryTriggerInteraction);
private static bool Internal_CapsuleCast(Vector3 point1, Vector3 point2, float radius, Vector3 direction, out RaycastHit hitInfo, float maxDistance, int layerMask, QueryTriggerInteraction queryTriggerInteraction)
{
float dirLength = direction.magnitude;
hitInfo = new RaycastHit();
if (dirLength > float.Epsilon)
{
Vector3 normalizedDirection = direction / dirLength;
return Query_CapsuleCast(point1, point2, radius, normalizedDirection, maxDistance, ref hitInfo, layerMask, queryTriggerInteraction);
}
else
return false;
}
static public bool CapsuleCast(Vector3 point1, Vector3 point2, float radius, Vector3 direction, [DefaultValue("Mathf.Infinity")] float maxDistance, [DefaultValue("DefaultRaycastLayers")] int layerMask, [DefaultValue("QueryTriggerInteraction.UseGlobal")] QueryTriggerInteraction queryTriggerInteraction)
{
RaycastHit hitInfo;
return Internal_CapsuleCast(point1, point2, radius, direction, out hitInfo, maxDistance, layerMask, queryTriggerInteraction);
}
[ExcludeFromDocs]
static public bool CapsuleCast(Vector3 point1, Vector3 point2, float radius, Vector3 direction, float maxDistance, int layerMask)
{
return CapsuleCast(point1, point2, radius, direction, maxDistance, layerMask, QueryTriggerInteraction.UseGlobal);
}
[ExcludeFromDocs]
static public bool CapsuleCast(Vector3 point1, Vector3 point2, float radius, Vector3 direction, float maxDistance)
{
return CapsuleCast(point1, point2, radius, direction, maxDistance, DefaultRaycastLayers, QueryTriggerInteraction.UseGlobal);
}
[ExcludeFromDocs]
static public bool CapsuleCast(Vector3 point1, Vector3 point2, float radius, Vector3 direction)
{
return CapsuleCast(point1, point2, radius, direction, Mathf.Infinity, DefaultRaycastLayers, QueryTriggerInteraction.UseGlobal);
}
static public bool CapsuleCast(Vector3 point1, Vector3 point2, float radius, Vector3 direction, out RaycastHit hitInfo, [DefaultValue("Mathf.Infinity")] float maxDistance, [DefaultValue("DefaultRaycastLayers")] int layerMask, [DefaultValue("QueryTriggerInteraction.UseGlobal")] QueryTriggerInteraction queryTriggerInteraction)
{
return Internal_CapsuleCast(point1, point2, radius, direction, out hitInfo, maxDistance, layerMask, queryTriggerInteraction);
}
[ExcludeFromDocs]
static public bool CapsuleCast(Vector3 point1, Vector3 point2, float radius, Vector3 direction, out RaycastHit hitInfo, float maxDistance, int layerMask)
{
return CapsuleCast(point1, point2, radius, direction, out hitInfo, maxDistance, layerMask, QueryTriggerInteraction.UseGlobal);
}
[ExcludeFromDocs]
static public bool CapsuleCast(Vector3 point1, Vector3 point2, float radius, Vector3 direction, out RaycastHit hitInfo, float maxDistance)
{
return CapsuleCast(point1, point2, radius, direction, out hitInfo, maxDistance, DefaultRaycastLayers, QueryTriggerInteraction.UseGlobal);
}
[ExcludeFromDocs]
static public bool CapsuleCast(Vector3 point1, Vector3 point2, float radius, Vector3 direction, out RaycastHit hitInfo)
{
return CapsuleCast(point1, point2, radius, direction, out hitInfo, Mathf.Infinity, DefaultRaycastLayers, QueryTriggerInteraction.UseGlobal);
}
static public bool SphereCast(Vector3 origin, float radius, Vector3 direction, out RaycastHit hitInfo, [DefaultValue("Mathf.Infinity")] float maxDistance, [DefaultValue("DefaultRaycastLayers")] int layerMask, [DefaultValue("QueryTriggerInteraction.UseGlobal")] QueryTriggerInteraction queryTriggerInteraction)
{
return Internal_CapsuleCast(origin, origin, radius, direction, out hitInfo, maxDistance, layerMask, queryTriggerInteraction);
}
[ExcludeFromDocs]
static public bool SphereCast(Vector3 origin, float radius, Vector3 direction, out RaycastHit hitInfo, float maxDistance, int layerMask)
{
return SphereCast(origin, radius, direction, out hitInfo, maxDistance, layerMask, QueryTriggerInteraction.UseGlobal);
}
[ExcludeFromDocs]
static public bool SphereCast(Vector3 origin, float radius, Vector3 direction, out RaycastHit hitInfo, float maxDistance)
{
return SphereCast(origin, radius, direction, out hitInfo, maxDistance, DefaultRaycastLayers, QueryTriggerInteraction.UseGlobal);
}
[ExcludeFromDocs]
static public bool SphereCast(Vector3 origin, float radius, Vector3 direction, out RaycastHit hitInfo)
{
return SphereCast(origin, radius, direction, out hitInfo, Mathf.Infinity, DefaultRaycastLayers, QueryTriggerInteraction.UseGlobal);
}
static public bool SphereCast(Ray ray, float radius, [DefaultValue("Mathf.Infinity")] float maxDistance, [DefaultValue("DefaultRaycastLayers")] int layerMask, [DefaultValue("QueryTriggerInteraction.UseGlobal")] QueryTriggerInteraction queryTriggerInteraction)
{
RaycastHit hitInfo;
return Internal_CapsuleCast(ray.origin, ray.origin, radius, ray.direction, out hitInfo, maxDistance, layerMask, queryTriggerInteraction);
}
[ExcludeFromDocs]
static public bool SphereCast(Ray ray, float radius, float maxDistance, int layerMask)
{
return SphereCast(ray, radius, maxDistance, layerMask, QueryTriggerInteraction.UseGlobal);
}
[ExcludeFromDocs]
static public bool SphereCast(Ray ray, float radius, float maxDistance)
{
return SphereCast(ray, radius, maxDistance, DefaultRaycastLayers, QueryTriggerInteraction.UseGlobal);
}
[ExcludeFromDocs]
static public bool SphereCast(Ray ray, float radius)
{
return SphereCast(ray, radius, Mathf.Infinity, DefaultRaycastLayers, QueryTriggerInteraction.UseGlobal);
}
static public bool SphereCast(Ray ray, float radius, out RaycastHit hitInfo, [DefaultValue("Mathf.Infinity")] float maxDistance, [DefaultValue("DefaultRaycastLayers")] int layerMask, [DefaultValue("QueryTriggerInteraction.UseGlobal")] QueryTriggerInteraction queryTriggerInteraction)
{
return Internal_CapsuleCast(ray.origin, ray.origin, radius, ray.direction, out hitInfo, maxDistance, layerMask, queryTriggerInteraction);
}
[ExcludeFromDocs]
static public bool SphereCast(Ray ray, float radius, out RaycastHit hitInfo, float maxDistance, int layerMask)
{
return SphereCast(ray, radius, out hitInfo, maxDistance, layerMask, QueryTriggerInteraction.UseGlobal);
}
[ExcludeFromDocs]
static public bool SphereCast(Ray ray, float radius, out RaycastHit hitInfo, float maxDistance)
{
return SphereCast(ray, radius, out hitInfo, maxDistance, DefaultRaycastLayers, QueryTriggerInteraction.UseGlobal);
}
[ExcludeFromDocs]
static public bool SphereCast(Ray ray, float radius, out RaycastHit hitInfo)
{
return SphereCast(ray, radius, out hitInfo, Mathf.Infinity, DefaultRaycastLayers, QueryTriggerInteraction.UseGlobal);
}
[NativeName("BoxCast")]
[StaticAccessor("GetPhysicsManager().GetPhysicsQuery()", StaticAccessorType.Dot)]
extern static private bool Query_BoxCast(Vector3 center, Vector3 halfExtents, Vector3 direction, Quaternion orientation, float maxDistance, ref RaycastHit outHit, int layerMask, QueryTriggerInteraction queryTriggerInteraction);
private static bool Internal_BoxCast(Vector3 center, Vector3 halfExtents, Quaternion orientation, Vector3 direction, out RaycastHit hitInfo, float maxDistance, int layerMask, QueryTriggerInteraction queryTriggerInteraction)
{
float dirLength = direction.magnitude;
hitInfo = new RaycastHit();
if (dirLength > float.Epsilon)
{
Vector3 normalizedDirection = direction / dirLength;
return Query_BoxCast(center, halfExtents, normalizedDirection, orientation, maxDistance, ref hitInfo, layerMask, queryTriggerInteraction);
}
else
return false;