mirror of
https://github.com/BlackMATov/unity-iso-tools.git
synced 2025-12-15 01:12:05 +07:00
physics to addons
This commit is contained in:
9
Assets/IsoTools/Addons/Physics.meta
Normal file
9
Assets/IsoTools/Addons/Physics.meta
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 8dd47e4d38ef9485586318e48755aff9
|
||||||
|
folderAsset: yes
|
||||||
|
timeCreated: 1480174284
|
||||||
|
licenseType: Free
|
||||||
|
DefaultImporter:
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
9
Assets/IsoTools/Addons/Physics/Internal.meta
Normal file
9
Assets/IsoTools/Addons/Physics/Internal.meta
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: e3a035a6c93424c7a98d81c8cb5aad1c
|
||||||
|
folderAsset: yes
|
||||||
|
timeCreated: 1480174340
|
||||||
|
licenseType: Free
|
||||||
|
DefaultImporter:
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace IsoTools.Internal {
|
namespace IsoTools.Physics.Internal {
|
||||||
public class IsoFakeCollider : MonoBehaviour {
|
public class IsoFakeCollider : MonoBehaviour {
|
||||||
IsoCollider _isoCollider = null;
|
IsoCollider _isoCollider = null;
|
||||||
|
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace IsoTools.Internal {
|
namespace IsoTools.Physics.Internal {
|
||||||
public class IsoFakeCollisionListener : MonoBehaviour {
|
public class IsoFakeCollisionListener : MonoBehaviour {
|
||||||
GameObject _realGameObject = null;
|
GameObject _realGameObject = null;
|
||||||
|
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace IsoTools.Internal {
|
namespace IsoTools.Physics.Internal {
|
||||||
public class IsoFakeObject : MonoBehaviour {
|
public class IsoFakeObject : MonoBehaviour {
|
||||||
|
|
||||||
IsoObject _isoObject = null;
|
IsoObject _isoObject = null;
|
||||||
@@ -25,9 +25,9 @@ namespace IsoTools.Internal {
|
|||||||
|
|
||||||
void FixedUpdate() {
|
void FixedUpdate() {
|
||||||
CheckLayers();
|
CheckLayers();
|
||||||
if ( !IsoUtils.Vec3Approximately(_lastPosition, isoObject.position) ) {
|
if ( _lastPosition != isoObject.position ) {
|
||||||
_lastPosition = transform.position = isoObject.position;
|
_lastPosition = transform.position = isoObject.position;
|
||||||
} else if ( !IsoUtils.Vec3Approximately(_lastPosition, transform.position) ) {
|
} else if ( _lastPosition != transform.position ) {
|
||||||
_lastPosition = isoObject.position = transform.position;
|
_lastPosition = isoObject.position = transform.position;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace IsoTools.Internal {
|
namespace IsoTools.Physics.Internal {
|
||||||
public class IsoFakeRigidbody : MonoBehaviour {
|
public class IsoFakeRigidbody : MonoBehaviour {
|
||||||
IsoRigidbody _isoRigidbody = null;
|
IsoRigidbody _isoRigidbody = null;
|
||||||
|
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace IsoTools.Internal {
|
namespace IsoTools.Physics.Internal {
|
||||||
public class IsoFakeTriggerListener : MonoBehaviour {
|
public class IsoFakeTriggerListener : MonoBehaviour {
|
||||||
GameObject _realGameObject = null;
|
GameObject _realGameObject = null;
|
||||||
|
|
||||||
@@ -12,14 +12,14 @@ namespace IsoTools.Internal {
|
|||||||
void OnTriggerEnter(Collider collider) {
|
void OnTriggerEnter(Collider collider) {
|
||||||
_realGameObject.SendMessage(
|
_realGameObject.SendMessage(
|
||||||
"OnIsoTriggerEnter",
|
"OnIsoTriggerEnter",
|
||||||
IsoUtils.IsoConvertCollider(collider),
|
IsoPhysicsUtils.IsoConvertCollider(collider),
|
||||||
SendMessageOptions.DontRequireReceiver);
|
SendMessageOptions.DontRequireReceiver);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnTriggerExit(Collider collider) {
|
void OnTriggerExit(Collider collider) {
|
||||||
_realGameObject.SendMessage(
|
_realGameObject.SendMessage(
|
||||||
"OnIsoTriggerExit",
|
"OnIsoTriggerExit",
|
||||||
IsoUtils.IsoConvertCollider(collider),
|
IsoPhysicsUtils.IsoConvertCollider(collider),
|
||||||
SendMessageOptions.DontRequireReceiver);
|
SendMessageOptions.DontRequireReceiver);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace IsoTools.Internal {
|
namespace IsoTools.Physics.Internal {
|
||||||
[DisallowMultipleComponent]
|
[DisallowMultipleComponent]
|
||||||
[RequireComponent(typeof(IsoObject))]
|
[RequireComponent(typeof(IsoObject))]
|
||||||
public class IsoPhysicHelper : MonoBehaviour {
|
public class IsoPhysicsHelper : MonoBehaviour {
|
||||||
|
|
||||||
GameObject _isoFakeObject = null;
|
GameObject _isoFakeObject = null;
|
||||||
public GameObject isoFakeObject {
|
public GameObject isoFakeObject {
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
using UnityEngine;
|
||||||
|
using IsoTools.Internal;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace IsoTools.Physics.Internal {
|
||||||
|
public class IsoPhysicsHelperHolder : MonoBehaviour {
|
||||||
|
|
||||||
|
static List<IsoPhysicsHelperHolder> _tmpHolders = new List<IsoPhysicsHelperHolder>(7);
|
||||||
|
|
||||||
|
protected GameObject fakeObject {
|
||||||
|
get { return physicsHelper.isoFakeObject; }
|
||||||
|
}
|
||||||
|
|
||||||
|
protected IsoPhysicsHelper physicsHelper {
|
||||||
|
get { return IsoUtils.GetOrCreateComponent<IsoPhysicsHelper>(gameObject); }
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void DestroyUnnecessaryCheck() {
|
||||||
|
GetComponents<IsoPhysicsHelperHolder>(_tmpHolders);
|
||||||
|
if ( _tmpHolders.Count == 1 && _tmpHolders[0] == this ) {
|
||||||
|
Destroy(physicsHelper);
|
||||||
|
}
|
||||||
|
_tmpHolders.Clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
37
Assets/IsoTools/Addons/Physics/Internal/IsoPhysicsUtils.cs
Normal file
37
Assets/IsoTools/Addons/Physics/Internal/IsoPhysicsUtils.cs
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace IsoTools.Physics.Internal {
|
||||||
|
public static class IsoPhysicsUtils {
|
||||||
|
public static IsoCollider IsoConvertCollider(Collider collider) {
|
||||||
|
var fake_collider = collider ? collider.GetComponent<IsoFakeCollider>() : null;
|
||||||
|
return fake_collider ? fake_collider.isoCollider : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static IsoRigidbody IsoConvertRigidbody(Rigidbody rigidbody) {
|
||||||
|
var fake_rigidbody = rigidbody ? rigidbody.GetComponent<IsoFakeRigidbody>() : null;
|
||||||
|
return fake_rigidbody ? fake_rigidbody.isoRigidbody : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static GameObject IsoConvertGameObject(GameObject game_object) {
|
||||||
|
var fake_object = game_object ? game_object.GetComponent<IsoFakeObject>() : null;
|
||||||
|
var iso_object = fake_object ? fake_object.isoObject : null;
|
||||||
|
return iso_object ? iso_object.gameObject : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static IsoContactPoint[] IsoConvertContactPoints(ContactPoint[] points) {
|
||||||
|
var iso_points = new IsoContactPoint[points.Length];
|
||||||
|
for ( int i = 0, e = points.Length; i < e; ++i ) {
|
||||||
|
iso_points[i] = new IsoContactPoint(points[i]);
|
||||||
|
}
|
||||||
|
return iso_points;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static IsoRaycastHit[] IsoConvertRaycastHits(RaycastHit[] hits) {
|
||||||
|
var iso_hits = new IsoRaycastHit[hits.Length];
|
||||||
|
for ( int i = 0, e = hits.Length; i < e; ++i ) {
|
||||||
|
iso_hits[i] = new IsoRaycastHit(hits[i]);
|
||||||
|
}
|
||||||
|
return iso_hits;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 0d44532ca15804cdc997583d81cf4df1
|
||||||
|
timeCreated: 1480196616
|
||||||
|
licenseType: Free
|
||||||
|
MonoImporter:
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -5,7 +5,7 @@ using IsoTools.Internal;
|
|||||||
using UnityEditor;
|
using UnityEditor;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace IsoTools {
|
namespace IsoTools.Physics {
|
||||||
[RequireComponent(typeof(IsoObject))]
|
[RequireComponent(typeof(IsoObject))]
|
||||||
public class IsoBoxCollider : IsoCollider {
|
public class IsoBoxCollider : IsoCollider {
|
||||||
|
|
||||||
@@ -5,7 +5,7 @@ using IsoTools.Internal;
|
|||||||
using UnityEditor;
|
using UnityEditor;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace IsoTools {
|
namespace IsoTools.Physics {
|
||||||
[RequireComponent(typeof(IsoObject))]
|
[RequireComponent(typeof(IsoObject))]
|
||||||
public class IsoCapsuleCollider : IsoCollider {
|
public class IsoCapsuleCollider : IsoCollider {
|
||||||
|
|
||||||
@@ -1,13 +1,13 @@
|
|||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using IsoTools.Internal;
|
using IsoTools.Physics.Internal;
|
||||||
|
|
||||||
#if UNITY_EDITOR
|
#if UNITY_EDITOR
|
||||||
using UnityEditor;
|
using UnityEditor;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace IsoTools {
|
namespace IsoTools.Physics {
|
||||||
[RequireComponent(typeof(IsoObject))]
|
[RequireComponent(typeof(IsoObject))]
|
||||||
public abstract class IsoCollider : IsoPhysicHelperHolder {
|
public abstract class IsoCollider : IsoPhysicsHelperHolder {
|
||||||
protected abstract Collider CreateRealCollider(GameObject target);
|
protected abstract Collider CreateRealCollider(GameObject target);
|
||||||
|
|
||||||
IsoFakeCollider _fakeCollider;
|
IsoFakeCollider _fakeCollider;
|
||||||
@@ -44,7 +44,7 @@ namespace IsoTools {
|
|||||||
public IsoRigidbody attachedRigidbody {
|
public IsoRigidbody attachedRigidbody {
|
||||||
get {
|
get {
|
||||||
return realCollider
|
return realCollider
|
||||||
? IsoUtils.IsoConvertRigidbody(realCollider.attachedRigidbody)
|
? IsoPhysicsUtils.IsoConvertRigidbody(realCollider.attachedRigidbody)
|
||||||
: null;
|
: null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using IsoTools.Internal;
|
using IsoTools.Physics.Internal;
|
||||||
|
|
||||||
namespace IsoTools {
|
namespace IsoTools.Physics {
|
||||||
public class IsoCollision {
|
public class IsoCollision {
|
||||||
|
|
||||||
public IsoCollider collider { get; private set; }
|
public IsoCollider collider { get; private set; }
|
||||||
@@ -12,12 +12,12 @@ namespace IsoTools {
|
|||||||
public IsoRigidbody rigidbody { get; private set; }
|
public IsoRigidbody rigidbody { get; private set; }
|
||||||
|
|
||||||
public IsoCollision(Collision collision) {
|
public IsoCollision(Collision collision) {
|
||||||
collider = IsoUtils.IsoConvertCollider(collision.collider);
|
collider = IsoPhysicsUtils.IsoConvertCollider(collision.collider);
|
||||||
contacts = IsoUtils.IsoConvertContactPoints(collision.contacts);
|
contacts = IsoPhysicsUtils.IsoConvertContactPoints(collision.contacts);
|
||||||
gameObject = IsoUtils.IsoConvertGameObject(collision.gameObject);
|
gameObject = IsoPhysicsUtils.IsoConvertGameObject(collision.gameObject);
|
||||||
impulse = collision.impulse;
|
impulse = collision.impulse;
|
||||||
relativeVelocity = collision.relativeVelocity;
|
relativeVelocity = collision.relativeVelocity;
|
||||||
rigidbody = IsoUtils.IsoConvertRigidbody(collision.rigidbody);
|
rigidbody = IsoPhysicsUtils.IsoConvertRigidbody(collision.rigidbody);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,10 +1,10 @@
|
|||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using IsoTools.Internal;
|
using IsoTools.Physics.Internal;
|
||||||
|
|
||||||
namespace IsoTools {
|
namespace IsoTools.Physics {
|
||||||
[DisallowMultipleComponent]
|
[DisallowMultipleComponent]
|
||||||
[RequireComponent(typeof(IsoObject))]
|
[RequireComponent(typeof(IsoObject))]
|
||||||
public class IsoCollisionListener : IsoPhysicHelperHolder {
|
public class IsoCollisionListener : IsoPhysicsHelperHolder {
|
||||||
|
|
||||||
IsoFakeCollisionListener _fakeListener;
|
IsoFakeCollisionListener _fakeListener;
|
||||||
|
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using IsoTools.Internal;
|
using IsoTools.Physics.Internal;
|
||||||
|
|
||||||
namespace IsoTools {
|
namespace IsoTools.Physics {
|
||||||
public struct IsoContactPoint {
|
public struct IsoContactPoint {
|
||||||
|
|
||||||
public Vector3 normal { get; private set; }
|
public Vector3 normal { get; private set; }
|
||||||
@@ -12,10 +12,10 @@ namespace IsoTools {
|
|||||||
|
|
||||||
public IsoContactPoint(ContactPoint contact_point) : this() {
|
public IsoContactPoint(ContactPoint contact_point) : this() {
|
||||||
normal = contact_point.normal;
|
normal = contact_point.normal;
|
||||||
otherCollider = IsoUtils.IsoConvertCollider(contact_point.otherCollider);
|
otherCollider = IsoPhysicsUtils.IsoConvertCollider(contact_point.otherCollider);
|
||||||
point = contact_point.point;
|
point = contact_point.point;
|
||||||
separation = contact_point.separation;
|
separation = contact_point.separation;
|
||||||
thisCollider = IsoUtils.IsoConvertCollider(contact_point.thisCollider);
|
thisCollider = IsoPhysicsUtils.IsoConvertCollider(contact_point.thisCollider);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
120
Assets/IsoTools/Addons/Physics/IsoPhysics.cs
Normal file
120
Assets/IsoTools/Addons/Physics/IsoPhysics.cs
Normal file
@@ -0,0 +1,120 @@
|
|||||||
|
using UnityEngine;
|
||||||
|
using IsoTools.Physics.Internal;
|
||||||
|
|
||||||
|
namespace IsoTools.Physics {
|
||||||
|
public static class IsoPhysics {
|
||||||
|
|
||||||
|
//
|
||||||
|
// Raycast
|
||||||
|
//
|
||||||
|
|
||||||
|
public static bool Raycast(Ray ray, out IsoRaycastHit iso_hit_info) {
|
||||||
|
return Raycast(ray, out iso_hit_info,
|
||||||
|
Mathf.Infinity, UnityEngine.Physics.DefaultRaycastLayers,
|
||||||
|
QueryTriggerInteraction.UseGlobal);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool Raycast(Ray ray, out IsoRaycastHit iso_hit_info,
|
||||||
|
float max_distance)
|
||||||
|
{
|
||||||
|
return Raycast(ray, out iso_hit_info,
|
||||||
|
max_distance, UnityEngine.Physics.DefaultRaycastLayers,
|
||||||
|
QueryTriggerInteraction.UseGlobal);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool Raycast(Ray ray, out IsoRaycastHit iso_hit_info,
|
||||||
|
float max_distance, int layer_mask)
|
||||||
|
{
|
||||||
|
return Raycast(ray, out iso_hit_info,
|
||||||
|
max_distance, layer_mask,
|
||||||
|
QueryTriggerInteraction.UseGlobal);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool Raycast(Ray ray, out IsoRaycastHit iso_hit_info,
|
||||||
|
float max_distance, int layer_mask,
|
||||||
|
QueryTriggerInteraction query_trigger_interaction)
|
||||||
|
{
|
||||||
|
var hit_info = new RaycastHit();
|
||||||
|
var result = UnityEngine.Physics.Raycast(ray, out hit_info,
|
||||||
|
max_distance, layer_mask, query_trigger_interaction);
|
||||||
|
iso_hit_info = result ? new IsoRaycastHit(hit_info) : new IsoRaycastHit();
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// RaycastAll
|
||||||
|
//
|
||||||
|
|
||||||
|
public static IsoRaycastHit[] RaycastAll(Ray ray) {
|
||||||
|
return RaycastAll(ray,
|
||||||
|
Mathf.Infinity, UnityEngine.Physics.DefaultRaycastLayers,
|
||||||
|
QueryTriggerInteraction.UseGlobal);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static IsoRaycastHit[] RaycastAll(Ray ray,
|
||||||
|
float max_distance)
|
||||||
|
{
|
||||||
|
return RaycastAll(ray,
|
||||||
|
max_distance, UnityEngine.Physics.DefaultRaycastLayers,
|
||||||
|
QueryTriggerInteraction.UseGlobal);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static IsoRaycastHit[] RaycastAll(Ray ray,
|
||||||
|
float max_distance, int layer_mask)
|
||||||
|
{
|
||||||
|
return RaycastAll(ray,
|
||||||
|
max_distance, layer_mask,
|
||||||
|
QueryTriggerInteraction.UseGlobal);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static IsoRaycastHit[] RaycastAll(Ray ray,
|
||||||
|
float max_distance, int layer_mask,
|
||||||
|
QueryTriggerInteraction query_trigger_interaction)
|
||||||
|
{
|
||||||
|
var hits_info = UnityEngine.Physics.RaycastAll(ray,
|
||||||
|
max_distance, layer_mask, query_trigger_interaction);
|
||||||
|
return IsoPhysicsUtils.IsoConvertRaycastHits(hits_info);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// RaycastNonAlloc
|
||||||
|
//
|
||||||
|
|
||||||
|
public static int RaycastNonAlloc(Ray ray, IsoRaycastHit[] results) {
|
||||||
|
return RaycastNonAlloc(ray, results,
|
||||||
|
Mathf.Infinity, UnityEngine.Physics.DefaultRaycastLayers,
|
||||||
|
QueryTriggerInteraction.UseGlobal);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int RaycastNonAlloc(Ray ray, IsoRaycastHit[] results,
|
||||||
|
float max_distance)
|
||||||
|
{
|
||||||
|
return RaycastNonAlloc(ray, results,
|
||||||
|
max_distance, UnityEngine.Physics.DefaultRaycastLayers,
|
||||||
|
QueryTriggerInteraction.UseGlobal);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int RaycastNonAlloc(Ray ray, IsoRaycastHit[] results,
|
||||||
|
float max_distance, int layer_mask)
|
||||||
|
{
|
||||||
|
return RaycastNonAlloc(ray, results,
|
||||||
|
max_distance, layer_mask,
|
||||||
|
QueryTriggerInteraction.UseGlobal);
|
||||||
|
}
|
||||||
|
|
||||||
|
static RaycastHit[] _raycastNonAllocBuffer = new RaycastHit[128];
|
||||||
|
public static int RaycastNonAlloc(Ray ray, IsoRaycastHit[] results,
|
||||||
|
float max_distance, int layer_mask,
|
||||||
|
QueryTriggerInteraction query_trigger_interaction)
|
||||||
|
{
|
||||||
|
var hit_count = UnityEngine.Physics.RaycastNonAlloc(ray, _raycastNonAllocBuffer,
|
||||||
|
max_distance, layer_mask, query_trigger_interaction);
|
||||||
|
var min_hit_count = Mathf.Min(hit_count, results.Length);
|
||||||
|
for ( var i = 0; i < min_hit_count; ++i ) {
|
||||||
|
results[i] = new IsoRaycastHit(_raycastNonAllocBuffer[i]);
|
||||||
|
}
|
||||||
|
System.Array.Clear(_raycastNonAllocBuffer, 0, _raycastNonAllocBuffer.Length);
|
||||||
|
return min_hit_count;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
12
Assets/IsoTools/Addons/Physics/IsoPhysics.cs.meta
Normal file
12
Assets/IsoTools/Addons/Physics/IsoPhysics.cs.meta
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 40ab1c30204174ffa8d877e00af23a62
|
||||||
|
timeCreated: 1480174712
|
||||||
|
licenseType: Free
|
||||||
|
MonoImporter:
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using IsoTools.Internal;
|
using IsoTools.Physics.Internal;
|
||||||
|
|
||||||
namespace IsoTools {
|
namespace IsoTools.Physics {
|
||||||
public struct IsoRaycastHit {
|
public struct IsoRaycastHit {
|
||||||
|
|
||||||
public IsoCollider collider { get; private set; }
|
public IsoCollider collider { get; private set; }
|
||||||
@@ -11,11 +11,11 @@ namespace IsoTools {
|
|||||||
public IsoRigidbody rigidbody { get; private set; }
|
public IsoRigidbody rigidbody { get; private set; }
|
||||||
|
|
||||||
public IsoRaycastHit(RaycastHit hit_info) : this() {
|
public IsoRaycastHit(RaycastHit hit_info) : this() {
|
||||||
collider = IsoUtils.IsoConvertCollider(hit_info.collider);
|
collider = IsoPhysicsUtils.IsoConvertCollider(hit_info.collider);
|
||||||
distance = hit_info.distance;
|
distance = hit_info.distance;
|
||||||
normal = hit_info.normal;
|
normal = hit_info.normal;
|
||||||
point = hit_info.point;
|
point = hit_info.point;
|
||||||
rigidbody = IsoUtils.IsoConvertRigidbody(hit_info.rigidbody);
|
rigidbody = IsoPhysicsUtils.IsoConvertRigidbody(hit_info.rigidbody);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,14 +1,14 @@
|
|||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using IsoTools.Internal;
|
using IsoTools.Physics.Internal;
|
||||||
|
|
||||||
#if UNITY_EDITOR
|
#if UNITY_EDITOR
|
||||||
using UnityEditor;
|
using UnityEditor;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace IsoTools {
|
namespace IsoTools.Physics {
|
||||||
[DisallowMultipleComponent]
|
[DisallowMultipleComponent]
|
||||||
[RequireComponent(typeof(IsoObject))]
|
[RequireComponent(typeof(IsoObject))]
|
||||||
public class IsoRigidbody : IsoPhysicHelperHolder {
|
public class IsoRigidbody : IsoPhysicsHelperHolder {
|
||||||
|
|
||||||
IsoFakeRigidbody _fakeRigidbody;
|
IsoFakeRigidbody _fakeRigidbody;
|
||||||
|
|
||||||
@@ -330,7 +330,8 @@ namespace IsoTools {
|
|||||||
float max_distance, QueryTriggerInteraction query_trigger_interaction)
|
float max_distance, QueryTriggerInteraction query_trigger_interaction)
|
||||||
{
|
{
|
||||||
return realRigidbody
|
return realRigidbody
|
||||||
? IsoUtils.IsoConvertRaycastHits(realRigidbody.SweepTestAll(direction, max_distance, query_trigger_interaction))
|
? IsoPhysicsUtils.IsoConvertRaycastHits(
|
||||||
|
realRigidbody.SweepTestAll(direction, max_distance, query_trigger_interaction))
|
||||||
: new IsoRaycastHit[0];
|
: new IsoRaycastHit[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -5,7 +5,7 @@ using IsoTools.Internal;
|
|||||||
using UnityEditor;
|
using UnityEditor;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace IsoTools {
|
namespace IsoTools.Physics {
|
||||||
[RequireComponent(typeof(IsoObject))]
|
[RequireComponent(typeof(IsoObject))]
|
||||||
public class IsoSphereCollider : IsoCollider {
|
public class IsoSphereCollider : IsoCollider {
|
||||||
|
|
||||||
@@ -1,10 +1,10 @@
|
|||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using IsoTools.Internal;
|
using IsoTools.Physics.Internal;
|
||||||
|
|
||||||
namespace IsoTools {
|
namespace IsoTools.Physics {
|
||||||
[DisallowMultipleComponent]
|
[DisallowMultipleComponent]
|
||||||
[RequireComponent(typeof(IsoObject))]
|
[RequireComponent(typeof(IsoObject))]
|
||||||
public class IsoTriggerListener : IsoPhysicHelperHolder {
|
public class IsoTriggerListener : IsoPhysicsHelperHolder {
|
||||||
|
|
||||||
IsoFakeTriggerListener _fakeListener;
|
IsoFakeTriggerListener _fakeListener;
|
||||||
|
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
using IsoTools.Physics;
|
||||||
|
|
||||||
namespace IsoTools.Examples.Dragosha {
|
namespace IsoTools.Examples.Dragosha {
|
||||||
[RequireComponent(typeof(IsoRigidbody))]
|
[RequireComponent(typeof(IsoRigidbody))]
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
using IsoTools.Physics;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
|
|
||||||
namespace IsoTools.Examples.Kenney {
|
namespace IsoTools.Examples.Kenney {
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
using IsoTools.Physics;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
|
|
||||||
namespace IsoTools.Examples.Kenney {
|
namespace IsoTools.Examples.Kenney {
|
||||||
@@ -8,7 +9,7 @@ namespace IsoTools.Examples.Kenney {
|
|||||||
if ( iso_world && Input.GetMouseButtonDown(0) ) {
|
if ( iso_world && Input.GetMouseButtonDown(0) ) {
|
||||||
var iso_mouse_pos = iso_world.MouseIsoPosition();
|
var iso_mouse_pos = iso_world.MouseIsoPosition();
|
||||||
var ray_from_iso_camera = iso_world.RayFromIsoCameraToIsoPoint(iso_mouse_pos);
|
var ray_from_iso_camera = iso_world.RayFromIsoCameraToIsoPoint(iso_mouse_pos);
|
||||||
var hits = iso_world.RaycastAll(ray_from_iso_camera);
|
var hits = IsoPhysics.RaycastAll(ray_from_iso_camera);
|
||||||
for ( var i = 0; i < hits.Length; ++i ) {
|
for ( var i = 0; i < hits.Length; ++i ) {
|
||||||
var alien_go = hits[i].collider.gameObject;
|
var alien_go = hits[i].collider.gameObject;
|
||||||
if ( alien_go.GetComponent<AlienBallController>() ) {
|
if ( alien_go.GetComponent<AlienBallController>() ) {
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
using IsoTools.Physics;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
|
|
||||||
namespace IsoTools.Examples.Kenney {
|
namespace IsoTools.Examples.Kenney {
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
using IsoTools.Physics;
|
||||||
|
|
||||||
namespace IsoTools.Examples.Kenney {
|
namespace IsoTools.Examples.Kenney {
|
||||||
[RequireComponent(typeof(IsoRigidbody))]
|
[RequireComponent(typeof(IsoRigidbody))]
|
||||||
|
|||||||
@@ -1,25 +0,0 @@
|
|||||||
using UnityEngine;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
|
|
||||||
namespace IsoTools.Internal {
|
|
||||||
public class IsoPhysicHelperHolder : MonoBehaviour {
|
|
||||||
|
|
||||||
static List<IsoPhysicHelperHolder> _tmpHolders = new List<IsoPhysicHelperHolder>(7);
|
|
||||||
|
|
||||||
protected GameObject fakeObject {
|
|
||||||
get { return physicHelper.isoFakeObject; }
|
|
||||||
}
|
|
||||||
|
|
||||||
protected IsoPhysicHelper physicHelper {
|
|
||||||
get { return IsoUtils.GetOrCreateComponent<IsoPhysicHelper>(gameObject); }
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void DestroyUnnecessaryCheck() {
|
|
||||||
GetComponents<IsoPhysicHelperHolder>(_tmpHolders);
|
|
||||||
if ( _tmpHolders.Count == 1 && _tmpHolders[0] == this ) {
|
|
||||||
Destroy(physicHelper);
|
|
||||||
}
|
|
||||||
_tmpHolders.Clear();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user