add some extra assets FX and SFX
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace NobleMuffins.LimbHacker.Guts
|
||||
{
|
||||
public abstract class AbstractDisposableProduct: IDisposable
|
||||
{
|
||||
IEnumerable<IDisposable> dependencies;
|
||||
|
||||
public AbstractDisposableProduct(IEnumerable<IDisposable> dependecies)
|
||||
{
|
||||
this.dependencies = dependecies;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
foreach(var dependency in dependencies)
|
||||
{
|
||||
dependency.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 393b98cf83f194a5fb1bfd3ff004fbbd
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 40995
|
||||
packageName: Game Kit Controller - Shooter Melee Adventure FPS TPS Creator 3D +
|
||||
2.5D
|
||||
packageVersion: 3.77h
|
||||
assetPath: Assets/Game Kit Controller/Integrations/LimbHacker-master/Guts/AbstractDisposableProduct.cs
|
||||
uploadId: 889948
|
||||
@@ -0,0 +1,181 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace NobleMuffins.LimbHacker.Guts {
|
||||
|
||||
//This is an unsafe white-box class that is part of the Turbo Slicer black-box. The
|
||||
//differences between it and the .NET List are esoteric, specific and not relevant
|
||||
//to your needs.
|
||||
|
||||
//Do not, under any circumstances, see it as a faster List for general use.
|
||||
//Read on only if you are studying or modifying TurboSlice.
|
||||
|
||||
/* Shea's Law states, "The ability to improve a design occurs primarily at the interfaces.
|
||||
* This is also the prime location for screwing it up."
|
||||
*
|
||||
* This class provides nice examples of both.
|
||||
*
|
||||
* List.AddRange was eating up a large chunk of time according to the profiler. This method only
|
||||
* accepts IEnumerable. While this is good in its use case, it doesn't have access to the given
|
||||
* set's size and discovering its size creates a lot of unnecessary work. Therefore, the first
|
||||
* special feature of TurboList is that its interface lets it observe a given set's size.
|
||||
*
|
||||
* The second is more dangerous; its model is directly exposed. Another chunk of time spent was getting
|
||||
* at the data, copying it and sometimes simply getting an array from the List.
|
||||
*
|
||||
* Do not use this class for anything else and do not assume that this will make anything else faster.
|
||||
* It was designed to meet a particular use case - the Muffin Slicer's - and is a private subset of that class
|
||||
* for a reason.
|
||||
*/
|
||||
public class ArrayBuilder<T>: IList<T> {
|
||||
public T[] array;
|
||||
public int length = 0;
|
||||
|
||||
public T[] ToArray()
|
||||
{
|
||||
T[] a = new T[length];
|
||||
System.Array.Copy(array, a, length);
|
||||
return a;
|
||||
}
|
||||
|
||||
public ArrayBuilder(T[] copySource)
|
||||
{
|
||||
var capacity = RoundUpToNearestSquare(copySource.Length);
|
||||
array = new T[capacity];
|
||||
System.Array.Copy(copySource, array, copySource.Length);
|
||||
length = copySource.Length;
|
||||
}
|
||||
|
||||
public ArrayBuilder(): this(0) {
|
||||
}
|
||||
|
||||
public ArrayBuilder(int desiredCapacity)
|
||||
{
|
||||
var capacity = RoundUpToNearestSquare(desiredCapacity);
|
||||
array = new T[capacity];
|
||||
length = 0;
|
||||
}
|
||||
|
||||
public void EnsureCapacity(int i)
|
||||
{
|
||||
bool mustExpand = i > array.Length;
|
||||
|
||||
if(mustExpand)
|
||||
{
|
||||
System.Array.Resize<T>(ref array, RoundUpToNearestSquare(i));
|
||||
}
|
||||
}
|
||||
|
||||
public void AddArray(T[] source)
|
||||
{
|
||||
EnsureCapacity(source.Length + length);
|
||||
System.Array.Copy(source, 0, array, length, source.Length);
|
||||
length += source.Length;
|
||||
}
|
||||
|
||||
public void AddArray(T[] source, int count)
|
||||
{
|
||||
count = System.Math.Min(count, source.Length);
|
||||
EnsureCapacity(count + length);
|
||||
System.Array.Copy(source, 0, array, length, count);
|
||||
length += count;
|
||||
}
|
||||
|
||||
private int RoundUpToNearestSquare(int minimum) {
|
||||
int newCapacity = 1;
|
||||
do {
|
||||
newCapacity *= 2;
|
||||
}
|
||||
while(newCapacity < minimum);
|
||||
return newCapacity;
|
||||
}
|
||||
|
||||
public int Capacity
|
||||
{
|
||||
get
|
||||
{
|
||||
return array.Length;
|
||||
}
|
||||
}
|
||||
|
||||
public int Count {
|
||||
get {
|
||||
return length;
|
||||
}
|
||||
}
|
||||
|
||||
public T this [int index]
|
||||
{
|
||||
get
|
||||
{
|
||||
return array[index];
|
||||
}
|
||||
set
|
||||
{
|
||||
array[index] = value;
|
||||
}
|
||||
}
|
||||
|
||||
public void RemoveAt(int i)
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public void Insert(int index, T figure)
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public int IndexOf(T figure)
|
||||
{
|
||||
return System.Array.IndexOf(array, figure);
|
||||
}
|
||||
|
||||
public void Add (T item)
|
||||
{
|
||||
EnsureCapacity(length + 1);
|
||||
array[length] = item;
|
||||
length++;
|
||||
}
|
||||
|
||||
public bool Contains (T item)
|
||||
{
|
||||
throw new System.NotImplementedException ();
|
||||
}
|
||||
|
||||
public void CopyTo (T[] array, int arrayIndex)
|
||||
{
|
||||
throw new System.NotImplementedException ();
|
||||
}
|
||||
|
||||
public IEnumerator<T> GetEnumerator ()
|
||||
{
|
||||
throw new System.NotImplementedException ();
|
||||
}
|
||||
public void Clear() {
|
||||
length = 0;
|
||||
}
|
||||
|
||||
public object SyncRoot {
|
||||
get {
|
||||
throw new System.NotImplementedException ();
|
||||
}
|
||||
}
|
||||
|
||||
public bool Remove (T item)
|
||||
{
|
||||
throw new System.NotImplementedException ();
|
||||
}
|
||||
|
||||
public bool IsReadOnly {
|
||||
get {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator ()
|
||||
{
|
||||
return array.GetEnumerator();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ca71475b3d2fa064180fa2ed82f65045
|
||||
timeCreated: 1488541202
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 40995
|
||||
packageName: Game Kit Controller - Shooter Melee Adventure FPS TPS Creator 3D +
|
||||
2.5D
|
||||
packageVersion: 3.77h
|
||||
assetPath: Assets/Game Kit Controller/Integrations/LimbHacker-master/Guts/ArrayBuilder.cs
|
||||
uploadId: 889948
|
||||
@@ -0,0 +1,97 @@
|
||||
using System;
|
||||
|
||||
namespace NobleMuffins.LimbHacker.Guts
|
||||
{
|
||||
public class ArrayPool<TElement>
|
||||
{
|
||||
private readonly object key = new object ();
|
||||
|
||||
private readonly int poolSize;
|
||||
private readonly TElement[][] poolTable;
|
||||
private readonly bool[] useTable;
|
||||
|
||||
public ArrayPool (int poolSize)
|
||||
{
|
||||
this.poolSize = poolSize;
|
||||
poolTable = new TElement[poolSize][];
|
||||
useTable = new bool[poolSize];
|
||||
}
|
||||
|
||||
public DisposableBundle<TElement[]> Get (int desiredCapacity, bool clear)
|
||||
{
|
||||
TElement[] array = null;
|
||||
lock (key) {
|
||||
for(int i = 0; i < poolSize; i++) {
|
||||
if(!useTable[i] && !object.ReferenceEquals(poolTable[i], null) && poolTable[i].Length >= desiredCapacity) {
|
||||
array = poolTable[i];
|
||||
useTable[i] = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(array == null) {
|
||||
var capacity = RoundUpToNearestSquare(desiredCapacity);
|
||||
array = new TElement[capacity];
|
||||
}
|
||||
else if(clear) {
|
||||
for(int i = 0; i < array.Length; i++) {
|
||||
array[i] = default(TElement);
|
||||
}
|
||||
}
|
||||
return new DisposableBundle<TElement[]>(array, Release);
|
||||
}
|
||||
|
||||
public IDisposable Get(int desiredCapacity, bool clear, out TElement[] collection) {
|
||||
var bundle = Get(desiredCapacity, clear);
|
||||
collection = bundle.Object;
|
||||
return bundle;
|
||||
}
|
||||
|
||||
private void Release (TElement[] array)
|
||||
{
|
||||
lock(key) {
|
||||
var foundPlace = false;
|
||||
|
||||
//First try to find its place, if it's already in the pool table.
|
||||
for(int i = 0; i < poolSize; i++) {
|
||||
if(object.ReferenceEquals(poolTable[i], array)) {
|
||||
useTable[i] = false;
|
||||
foundPlace = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//If that failed, than try to find an empty slot.
|
||||
if(foundPlace == false) {
|
||||
for(int i = 0; i < poolSize; i++) {
|
||||
if(object.ReferenceEquals(poolTable[i], null)) {
|
||||
poolTable[i] = array;
|
||||
useTable[i] = false;
|
||||
foundPlace = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//If that failed, than try to find a smaller collection that isn't in use and replace it.
|
||||
if(foundPlace == false) {
|
||||
for(int i = 0; i < poolSize; i++) {
|
||||
if(!useTable[i] && !object.ReferenceEquals(poolTable[i], null) && poolTable[i].Length < array.Length) {
|
||||
poolTable[i] = array;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private int RoundUpToNearestSquare(int minimum) {
|
||||
int newCapacity = 1;
|
||||
do {
|
||||
newCapacity *= 2;
|
||||
}
|
||||
while(newCapacity < minimum);
|
||||
return newCapacity;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 68409e20be087364bb94e44e4310390a
|
||||
timeCreated: 1488541205
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 40995
|
||||
packageName: Game Kit Controller - Shooter Melee Adventure FPS TPS Creator 3D +
|
||||
2.5D
|
||||
packageVersion: 3.77h
|
||||
assetPath: Assets/Game Kit Controller/Integrations/LimbHacker-master/Guts/ArrayPool.cs
|
||||
uploadId: 889948
|
||||
@@ -0,0 +1,18 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace NobleMuffins.LimbHacker.Guts
|
||||
{
|
||||
public class BoneMetadata
|
||||
{
|
||||
public BoneMetadata(int index, string nameInViewGraph, Matrix4x4 bindPose)
|
||||
{
|
||||
Index = index;
|
||||
NameInViewGraph = nameInViewGraph;
|
||||
BindPose = bindPose;
|
||||
}
|
||||
|
||||
public int Index { get; private set; }
|
||||
public string NameInViewGraph { get; private set; }
|
||||
public Matrix4x4 BindPose { get; private set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 41b3baa47fe006b4580834a7d8339eda
|
||||
timeCreated: 1488443658
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 40995
|
||||
packageName: Game Kit Controller - Shooter Melee Adventure FPS TPS Creator 3D +
|
||||
2.5D
|
||||
packageVersion: 3.77h
|
||||
assetPath: Assets/Game Kit Controller/Integrations/LimbHacker-master/Guts/BoneMetadata.cs
|
||||
uploadId: 889948
|
||||
@@ -0,0 +1,27 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace NobleMuffins.LimbHacker.Guts
|
||||
{
|
||||
public class ChildOfHackable : MonoBehaviour, ISliceable
|
||||
{
|
||||
[HideInInspector]
|
||||
public Hackable parentHackable;
|
||||
|
||||
void Start ()
|
||||
{
|
||||
if (parentHackable == null) {
|
||||
Debug.LogWarning ("Unconfigured ChildOfHackable found. Removing. If you added this to an object yourself, please remove it.");
|
||||
GameObject.DestroyImmediate (this);
|
||||
}
|
||||
}
|
||||
|
||||
void ISliceable.Slice (Vector3 positionInWorldSpace, Vector3 normalInWorldSpace)
|
||||
{
|
||||
parentHackable.Slice (positionInWorldSpace, normalInWorldSpace);
|
||||
}
|
||||
#pragma warning disable 0067
|
||||
public event EventHandler<SliceEventArgs> Sliced;
|
||||
#pragma warning restore 0067
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6547491be3d3f2047bb9029f766a7ebd
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 40995
|
||||
packageName: Game Kit Controller - Shooter Melee Adventure FPS TPS Creator 3D +
|
||||
2.5D
|
||||
packageVersion: 3.77h
|
||||
assetPath: Assets/Game Kit Controller/Integrations/LimbHacker-master/Guts/ChildOfHackable.cs
|
||||
uploadId: 889948
|
||||
@@ -0,0 +1,88 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace NobleMuffins.LimbHacker.Guts
|
||||
{
|
||||
public class CollectionPool<TCollection, TElement> where TCollection: class, ICollection<TElement>
|
||||
{
|
||||
private readonly object key = new object ();
|
||||
|
||||
private readonly int poolSize;
|
||||
private readonly TCollection[] poolTable;
|
||||
private readonly bool[] useTable;
|
||||
private readonly Func<int, TCollection> instantiateWithCapacity;
|
||||
private readonly Func<TCollection, int> getCapacity;
|
||||
|
||||
public CollectionPool (int poolSize, Func<TCollection, int> getCapacity, Func<int, TCollection> instantiateWithCapacity)
|
||||
{
|
||||
this.poolSize = poolSize;
|
||||
this.getCapacity = getCapacity;
|
||||
this.instantiateWithCapacity = instantiateWithCapacity;
|
||||
poolTable = new TCollection[poolSize];
|
||||
useTable = new bool[poolSize];
|
||||
}
|
||||
|
||||
public DisposableBundle<TCollection> Get (int desiredCapacity)
|
||||
{
|
||||
TCollection o = null;
|
||||
lock (key) {
|
||||
for(int i = 0; i < poolSize; i++) {
|
||||
if(!useTable[i] && !object.ReferenceEquals(poolTable[i], null) && getCapacity(poolTable[i]) >= desiredCapacity) {
|
||||
o = poolTable[i];
|
||||
o.Clear();
|
||||
useTable[i] = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(o == null) {
|
||||
o = instantiateWithCapacity(desiredCapacity);
|
||||
}
|
||||
return new DisposableBundle<TCollection>(o, Release);
|
||||
}
|
||||
|
||||
public IDisposable Get(int desiredCapacity, out TCollection collection) {
|
||||
var bundle = Get(desiredCapacity);
|
||||
collection = bundle.Object;
|
||||
return bundle;
|
||||
}
|
||||
|
||||
private void Release (TCollection o)
|
||||
{
|
||||
lock(key) {
|
||||
var foundPlace = false;
|
||||
|
||||
//First try to find its place, if it's already in the pool table.
|
||||
for(int i = 0; i < poolSize; i++) {
|
||||
if(object.ReferenceEquals(poolTable[i], o)) {
|
||||
useTable[i] = false;
|
||||
foundPlace = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//If that failed, than try to find an empty slot.
|
||||
if(foundPlace == false) {
|
||||
for(int i = 0; i < poolSize; i++) {
|
||||
if(object.ReferenceEquals(poolTable[i], null)) {
|
||||
poolTable[i] = o;
|
||||
useTable[i] = false;
|
||||
foundPlace = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//If that failed, than try to find a smaller collection that isn't in use and replace it.
|
||||
if(foundPlace == false) {
|
||||
for(int i = 0; i < poolSize; i++) {
|
||||
if(!useTable[i] && !object.ReferenceEquals(poolTable[i], null) && poolTable[i].Count < o.Count) {
|
||||
poolTable[i] = o;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f0bfe31883c77e045b6c78336c24c94d
|
||||
timeCreated: 1488541472
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 40995
|
||||
packageName: Game Kit Controller - Shooter Melee Adventure FPS TPS Creator 3D +
|
||||
2.5D
|
||||
packageVersion: 3.77h
|
||||
assetPath: Assets/Game Kit Controller/Integrations/LimbHacker-master/Guts/CollectionPool.cs
|
||||
uploadId: 889948
|
||||
@@ -0,0 +1,28 @@
|
||||
using System;
|
||||
|
||||
namespace NobleMuffins.LimbHacker.Guts
|
||||
{
|
||||
public class DisposableBundle<TObject>: IDisposable {
|
||||
public DisposableBundle(TObject datum, Action<TObject> callback) {
|
||||
this.datum = datum;
|
||||
this.callback = callback;
|
||||
disposed = false;
|
||||
}
|
||||
|
||||
private readonly TObject datum;
|
||||
private readonly Action<TObject> callback;
|
||||
private bool disposed;
|
||||
|
||||
public TObject Object { get {
|
||||
return datum;
|
||||
} }
|
||||
|
||||
public void Dispose() {
|
||||
if(!disposed) {
|
||||
disposed = true;
|
||||
callback(Object);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0da8d18f01e487546bb17a88240b45b8
|
||||
timeCreated: 1488541274
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 40995
|
||||
packageName: Game Kit Controller - Shooter Melee Adventure FPS TPS Creator 3D +
|
||||
2.5D
|
||||
packageVersion: 3.77h
|
||||
assetPath: Assets/Game Kit Controller/Integrations/LimbHacker-master/Guts/DisposableBundle.cs
|
||||
uploadId: 889948
|
||||
@@ -0,0 +1,9 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace NobleMuffins.LimbHacker.Guts
|
||||
{
|
||||
public class ForwardPassAgent : MonoBehaviour {
|
||||
public IEnumerable<MeshSnapshot> Snapshot { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6702f03e674fa534cb59ba5d812b638a
|
||||
timeCreated: 1487682864
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 40995
|
||||
packageName: Game Kit Controller - Shooter Melee Adventure FPS TPS Creator 3D +
|
||||
2.5D
|
||||
packageVersion: 3.77h
|
||||
assetPath: Assets/Game Kit Controller/Integrations/LimbHacker-master/Guts/ForwardPassAgent.cs
|
||||
uploadId: 889948
|
||||
@@ -0,0 +1,12 @@
|
||||
using UnityEngine;
|
||||
using System;
|
||||
|
||||
namespace NobleMuffins.LimbHacker.Guts
|
||||
{
|
||||
public interface ISliceable
|
||||
{
|
||||
void Slice (Vector3 positionInWorldSpace, Vector3 normalInWorldSpace);
|
||||
|
||||
event EventHandler<SliceEventArgs> Sliced;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bcc767bb9b7e87a4eae74de3cb16a718
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 40995
|
||||
packageName: Game Kit Controller - Shooter Melee Adventure FPS TPS Creator 3D +
|
||||
2.5D
|
||||
packageVersion: 3.77h
|
||||
assetPath: Assets/Game Kit Controller/Integrations/LimbHacker-master/Guts/ISliceable.cs
|
||||
uploadId: 889948
|
||||
@@ -0,0 +1,4 @@
|
||||
namespace NobleMuffins.LimbHacker.Guts
|
||||
{
|
||||
public enum InfillMode { Sloppy, Meticulous };
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c6dd1f49b6f4861409d411c9d30385fc
|
||||
timeCreated: 1490779351
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 40995
|
||||
packageName: Game Kit Controller - Shooter Melee Adventure FPS TPS Creator 3D +
|
||||
2.5D
|
||||
packageVersion: 3.77h
|
||||
assetPath: Assets/Game Kit Controller/Integrations/LimbHacker-master/Guts/Infill.cs
|
||||
uploadId: 889948
|
||||
@@ -0,0 +1,46 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace NobleMuffins.LimbHacker.Guts
|
||||
{
|
||||
public class JobSpecification
|
||||
{
|
||||
public JobSpecification(GameObject subject, Hackable hackable,
|
||||
IEnumerable<MeshSnapshot> meshSnapshots,
|
||||
Dictionary<string, NodeMetadata> nodeMetadata,
|
||||
Material infillMaterial,
|
||||
string jointName, float rootTipProgression, Vector3? tiltPlane, InfillMode infillMode,
|
||||
bool destroyOriginal) {
|
||||
Subject = subject;
|
||||
Hackable = hackable;
|
||||
MeshSnapshots = meshSnapshots;
|
||||
InfillMaterial = infillMaterial;
|
||||
NodeMetadata = nodeMetadata;
|
||||
JointName = jointName;
|
||||
RootTipProgression = rootTipProgression;
|
||||
TiltPlane = tiltPlane;
|
||||
InfillMode = infillMode;
|
||||
DestroyOriginal = destroyOriginal;
|
||||
}
|
||||
|
||||
public GameObject Subject { get; private set; }
|
||||
|
||||
public Hackable Hackable { get; private set; }
|
||||
|
||||
public Material InfillMaterial { get; private set; }
|
||||
|
||||
public bool DestroyOriginal { get; private set; }
|
||||
|
||||
public IEnumerable<MeshSnapshot> MeshSnapshots { get; private set; }
|
||||
|
||||
public Dictionary<string, NodeMetadata> NodeMetadata { get; private set; }
|
||||
|
||||
public string JointName { get; private set; }
|
||||
|
||||
public float RootTipProgression { get; private set; }
|
||||
|
||||
public Vector3? TiltPlane { get; private set; }
|
||||
|
||||
public InfillMode InfillMode { get; private set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2bc3a68970c1cd7448f8b20f3ddf557f
|
||||
timeCreated: 1487680054
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 40995
|
||||
packageName: Game Kit Controller - Shooter Melee Adventure FPS TPS Creator 3D +
|
||||
2.5D
|
||||
packageVersion: 3.77h
|
||||
assetPath: Assets/Game Kit Controller/Integrations/LimbHacker-master/Guts/JobSpecification.cs
|
||||
uploadId: 889948
|
||||
@@ -0,0 +1,44 @@
|
||||
using UnityEngine;
|
||||
using System;
|
||||
|
||||
namespace NobleMuffins.LimbHacker.Guts
|
||||
{
|
||||
public class JobState
|
||||
{
|
||||
public JobState(JobSpecification specification) {
|
||||
Specification = specification;
|
||||
}
|
||||
|
||||
public JobSpecification Specification { get; private set; }
|
||||
|
||||
JobYield yield;
|
||||
public JobYield Yield {
|
||||
get {
|
||||
return yield;
|
||||
}
|
||||
set {
|
||||
Debug.Assert(IsDone == false, "JobYield was given a yield more than once.");
|
||||
yield = value;
|
||||
HasYield = true;
|
||||
}
|
||||
}
|
||||
public bool HasYield { get; private set; }
|
||||
|
||||
Exception exception;
|
||||
public Exception Exception {
|
||||
get {
|
||||
return exception;
|
||||
}
|
||||
set {
|
||||
Debug.Assert(IsDone == false, "JobYield was given an exception more than once.");
|
||||
exception = value;
|
||||
HasException = true;
|
||||
}
|
||||
}
|
||||
public bool HasException { get; private set; }
|
||||
|
||||
public bool IsDone { get {
|
||||
return HasException || HasYield;
|
||||
} }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 44492980717cde24e82433f3c58428e3
|
||||
timeCreated: 1487680054
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 40995
|
||||
packageName: Game Kit Controller - Shooter Melee Adventure FPS TPS Creator 3D +
|
||||
2.5D
|
||||
packageVersion: 3.77h
|
||||
assetPath: Assets/Game Kit Controller/Integrations/LimbHacker-master/Guts/JobState.cs
|
||||
uploadId: 889948
|
||||
@@ -0,0 +1,23 @@
|
||||
using UnityEngine;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace NobleMuffins.LimbHacker.Guts
|
||||
{
|
||||
public class JobYield
|
||||
{
|
||||
public JobYield(JobSpecification job, Vector4 planeInWorldSpace, Vector3 focalPointInWorldSpace, IEnumerable<MeshSnapshot> alfa, IEnumerable<MeshSnapshot> bravo) {
|
||||
Job = job;
|
||||
PlaneInWorldSpace = planeInWorldSpace;
|
||||
FocalPointInWorldSpace = focalPointInWorldSpace;
|
||||
Alfa = alfa;
|
||||
Bravo = bravo;
|
||||
}
|
||||
|
||||
public JobSpecification Job { get; private set; }
|
||||
public Vector4 PlaneInWorldSpace { get; private set; }
|
||||
public IEnumerable<MeshSnapshot> Alfa { get; private set; }
|
||||
public IEnumerable<MeshSnapshot> Bravo { get; private set; }
|
||||
public Vector3 FocalPointInWorldSpace { get; private set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 49f1f8b86482ca94a8723e8e13dde502
|
||||
timeCreated: 1487680054
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 40995
|
||||
packageName: Game Kit Controller - Shooter Melee Adventure FPS TPS Creator 3D +
|
||||
2.5D
|
||||
packageVersion: 3.77h
|
||||
assetPath: Assets/Game Kit Controller/Integrations/LimbHacker-master/Guts/JobYield.cs
|
||||
uploadId: 889948
|
||||
@@ -0,0 +1,637 @@
|
||||
using UnityEngine;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace NobleMuffins.LimbHacker.Guts
|
||||
{
|
||||
public class LimbHackerAgent : MonoBehaviour
|
||||
{
|
||||
public Mesh[] preloadMeshes;
|
||||
public WorkerThreadMode workerThreadMode;
|
||||
|
||||
private readonly HashSet<JobState> jobStates = new HashSet<JobState> ();
|
||||
private readonly List<JobState> jobStateQueue = new List<JobState> ();
|
||||
private readonly ICollection<JobState> jobStateRemovalQueue = new List<JobState> ();
|
||||
|
||||
private readonly IDictionary<int, MeshSnapshot> preloadedMeshes = new Dictionary<int, MeshSnapshot> ();
|
||||
|
||||
private static LimbHackerAgent _instance;
|
||||
|
||||
public static LimbHackerAgent instance {
|
||||
get {
|
||||
if (_instance == null) {
|
||||
GameObject go = new GameObject ();
|
||||
_instance = go.AddComponent<LimbHackerAgent> ();
|
||||
}
|
||||
return _instance;
|
||||
}
|
||||
}
|
||||
|
||||
public void Awake ()
|
||||
{
|
||||
#if UNITY_WEBGL
|
||||
if (workerThreadMode == WorkerThreadMode.Asynchronous) {
|
||||
Debug.LogWarning ("Turbo Slicer will run synchronously because WebGL does not support threads.", this);
|
||||
workerThreadMode = WorkerThreadMode.Synchronous;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (preloadMeshes != null) {
|
||||
for (int i = 0; i < preloadMeshes.Length; i++) {
|
||||
var mesh = preloadMeshes [i];
|
||||
var indices = new int[mesh.subMeshCount][];
|
||||
for (int j = 0; j < mesh.subMeshCount; j++) {
|
||||
indices [j] = mesh.GetIndices (j);
|
||||
}
|
||||
|
||||
//Note that this is NOT a usable mesh snapshot. It will need to be combined with live data at runtime.
|
||||
var rom = new MeshSnapshot (null, mesh.vertices, mesh.normals, mesh.uv, mesh.tangents, mesh.boneWeights, new Material[0], new BoneMetadata[0], null, indices);
|
||||
preloadedMeshes [mesh.GetInstanceID ()] = rom;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Use this for initialization
|
||||
void Start ()
|
||||
{
|
||||
_instance = this;
|
||||
}
|
||||
|
||||
//These buffers are used in ConsumeJobYield. This method is executed only on the event dispatch thread and therefore will not be clobbered.
|
||||
readonly Dictionary<string, bool> bonePresenceAlfaBuffer = new Dictionary<string, bool> ();
|
||||
readonly Dictionary<string, bool> bonePresenceBravoBuffer = new Dictionary<string, bool> ();
|
||||
|
||||
void ConsumeJobYield (JobState jobState)
|
||||
{
|
||||
if (jobState.HasException) {
|
||||
Debug.LogException (jobState.Exception);
|
||||
} else {
|
||||
var jobSpecification = jobState.Specification;
|
||||
var jobYield = jobState.Yield;
|
||||
|
||||
bonePresenceAlfaBuffer.Clear ();
|
||||
bonePresenceBravoBuffer.Clear ();
|
||||
|
||||
foreach (var kvp in jobSpecification.NodeMetadata) {
|
||||
bonePresenceAlfaBuffer [kvp.Key] = kvp.Value.IsConsideredSevered;
|
||||
bonePresenceBravoBuffer [kvp.Key] = !kvp.Value.IsConsideredSevered;
|
||||
}
|
||||
|
||||
var originalSubjectTransform = jobSpecification.Subject.transform;
|
||||
|
||||
bool useAlternateForFront, useAlternateForBack;
|
||||
|
||||
if (jobSpecification.Hackable.alternatePrefab == null) {
|
||||
useAlternateForFront = false;
|
||||
useAlternateForBack = false;
|
||||
} else {
|
||||
useAlternateForFront = jobSpecification.Hackable.cloneAlternate (bonePresenceAlfaBuffer);
|
||||
useAlternateForBack = jobSpecification.Hackable.cloneAlternate (bonePresenceBravoBuffer);
|
||||
}
|
||||
|
||||
GameObject alfaObject, bravoObject;
|
||||
|
||||
var backIsNew = useAlternateForBack;
|
||||
|
||||
if (backIsNew) {
|
||||
var backSource = useAlternateForBack ? jobSpecification.Hackable.alternatePrefab : jobSpecification.Subject;
|
||||
bravoObject = (GameObject)Instantiate (backSource);
|
||||
bravoObject.name = string.Format ("{0} (Bravo)", jobSpecification.Subject);
|
||||
} else
|
||||
bravoObject = jobSpecification.Subject;
|
||||
|
||||
var alfaSource = useAlternateForFront ? jobSpecification.Hackable.alternatePrefab : jobSpecification.Subject;
|
||||
alfaObject = (GameObject)Instantiate (alfaSource);
|
||||
|
||||
HandleHierarchy (alfaObject.transform, bonePresenceAlfaBuffer, jobSpecification.NodeMetadata);
|
||||
HandleHierarchy (bravoObject.transform, bonePresenceBravoBuffer, jobSpecification.NodeMetadata);
|
||||
|
||||
var parent = originalSubjectTransform.parent;
|
||||
|
||||
var position = originalSubjectTransform.localPosition;
|
||||
var scale = originalSubjectTransform.localScale;
|
||||
|
||||
var rotation = originalSubjectTransform.localRotation;
|
||||
|
||||
alfaObject.transform.parent = parent;
|
||||
alfaObject.transform.localPosition = position;
|
||||
alfaObject.transform.localScale = scale;
|
||||
|
||||
alfaObject.transform.localRotation = rotation;
|
||||
|
||||
alfaObject.layer = jobSpecification.Subject.layer;
|
||||
|
||||
alfaObject.name = string.Format ("{0} (Alfa)", jobSpecification.Subject);
|
||||
|
||||
if (backIsNew) {
|
||||
bravoObject.transform.parent = parent;
|
||||
bravoObject.transform.localPosition = position;
|
||||
bravoObject.transform.localScale = scale;
|
||||
|
||||
bravoObject.transform.localRotation = rotation;
|
||||
|
||||
bravoObject.layer = jobSpecification.Subject.layer;
|
||||
}
|
||||
|
||||
ApplySnapshotsToRoot (alfaObject, jobYield.Alfa);
|
||||
ApplySnapshotsToRoot (bravoObject, jobYield.Bravo);
|
||||
|
||||
var results = new GameObject[] {
|
||||
alfaObject, bravoObject
|
||||
};
|
||||
|
||||
jobSpecification.Hackable.handleSlice (results, jobState.Yield.PlaneInWorldSpace, jobState.Yield.FocalPointInWorldSpace);
|
||||
|
||||
if (backIsNew) {
|
||||
// print ("destroy sliced object value " + jobSpecification.Hackable.ignoreDestroyOriginalObject);
|
||||
|
||||
if (jobSpecification.Hackable.ignoreDestroyOriginalObject) {
|
||||
jobSpecification.Hackable.eventsOnIgnoreDestroyOriginalObject.Invoke ();
|
||||
|
||||
if (jobSpecification.Hackable.setCustomIDOnSliceSpieces) {
|
||||
Hackable alfaObjectHackable = alfaObject.GetComponent<Hackable> ();
|
||||
|
||||
if (alfaObjectHackable != null) {
|
||||
alfaObjectHackable.setCustomIDOnSliceSpieces = true;
|
||||
|
||||
alfaObjectHackable.setRandomString (jobSpecification.Hackable.getRandomString ());
|
||||
}
|
||||
|
||||
Hackable bravoObjectHackable = bravoObject.GetComponent<Hackable> ();
|
||||
|
||||
if (bravoObjectHackable != null) {
|
||||
bravoObjectHackable.setCustomIDOnSliceSpieces = true;
|
||||
|
||||
bravoObjectHackable.setRandomString (jobSpecification.Hackable.getRandomString ());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Destroy (jobSpecification.Subject);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//These buffers are used in HandleHierarchy. This method is executed only on the event dispatch thread and therefore will not be clobbered.
|
||||
readonly ICollection<Transform> boneBuffer = new HashSet<Transform> ();
|
||||
readonly ICollection<GameObject> rendererHolderBuffer = new HashSet<GameObject> ();
|
||||
readonly List<Transform> childrenBuffer = new List<Transform> ();
|
||||
|
||||
private void HandleHierarchy (Transform root, Dictionary<string, bool> bonePresenceByName, IDictionary<string, NodeMetadata> originalsByName)
|
||||
{
|
||||
boneBuffer.Clear ();
|
||||
|
||||
var smrs = root.GetComponentsInChildren<SkinnedMeshRenderer> ();
|
||||
|
||||
rendererHolderBuffer.Clear ();
|
||||
|
||||
foreach (var smr in smrs) {
|
||||
rendererHolderBuffer.Add (smr.gameObject);
|
||||
|
||||
var _bones = smr.bones;
|
||||
|
||||
for (int i = 0; i < _bones.Length; i++) {
|
||||
var bone = _bones [i];
|
||||
|
||||
boneBuffer.Add (bone);
|
||||
|
||||
// Hierarchies often have transforms between bones and the root that are not
|
||||
// part of the bones collection pulled from the SMR. However if we turn these
|
||||
// intermediaries off, the ragdoll will not work. For the purposes of this
|
||||
// procedure, we're going to treat these AS bones.
|
||||
|
||||
boneBuffer.Add (bone.parent);
|
||||
}
|
||||
}
|
||||
|
||||
childrenBuffer.Clear ();
|
||||
if (childrenBuffer.Capacity < bonePresenceByName.Count) {
|
||||
childrenBuffer.Capacity = bonePresenceByName.Count;
|
||||
}
|
||||
|
||||
ConcatenateHierarchy (root, childrenBuffer);
|
||||
|
||||
for (int i = 0; i < childrenBuffer.Count; i++) {
|
||||
var t = childrenBuffer [i];
|
||||
var go = t.gameObject;
|
||||
var thisIsTheSkinnedMeshRenderer = rendererHolderBuffer.Contains (go);
|
||||
var shouldBePresent = true;
|
||||
|
||||
var presenceKeySource = t;
|
||||
do {
|
||||
string presenceKey = presenceKeySource.name;
|
||||
if (bonePresenceByName.ContainsKey (presenceKey)) {
|
||||
shouldBePresent = bonePresenceByName [presenceKey];
|
||||
break;
|
||||
} else {
|
||||
presenceKeySource = presenceKeySource.parent;
|
||||
}
|
||||
} while (childrenBuffer.Contains (presenceKeySource));
|
||||
|
||||
NodeMetadata sourceMetadata;
|
||||
if (originalsByName.TryGetValue (t.name, out sourceMetadata)) {
|
||||
t.localPosition = sourceMetadata.LocalPosition;
|
||||
t.localRotation = sourceMetadata.LocalRotation;
|
||||
t.localScale = sourceMetadata.LocalScale;
|
||||
|
||||
shouldBePresent &= sourceMetadata.IsActive;
|
||||
}
|
||||
|
||||
bool isBone = boneBuffer.Contains (t);
|
||||
|
||||
if (!shouldBePresent && isBone) {
|
||||
var c = t.GetComponent<Collider> ();
|
||||
if (c != null) {
|
||||
c.enabled = shouldBePresent;
|
||||
}
|
||||
|
||||
var r = t.GetComponent<Rigidbody> ();
|
||||
if (r != null) {
|
||||
r.mass = float.Epsilon;
|
||||
}
|
||||
} else {
|
||||
shouldBePresent |= thisIsTheSkinnedMeshRenderer;
|
||||
|
||||
go.SetActive (shouldBePresent || thisIsTheSkinnedMeshRenderer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private ICollection<Transform> GetConcatenatedHierarchy (Transform t)
|
||||
{
|
||||
var children = new HashSet<Transform> () as ICollection<Transform>;
|
||||
ConcatenateHierarchy (t, children);
|
||||
return children;
|
||||
}
|
||||
|
||||
static void ConcatenateHierarchy (Transform root, ICollection<Transform> resultBuffer)
|
||||
{
|
||||
for (int i = 0; i < root.childCount; i++) {
|
||||
var child = root.GetChild (i);
|
||||
resultBuffer.Add (child);
|
||||
ConcatenateHierarchy (child, resultBuffer);
|
||||
}
|
||||
}
|
||||
|
||||
static void ApplySnapshotsToRoot (GameObject root, IEnumerable<MeshSnapshot> snapshots)
|
||||
{
|
||||
var skinnedMeshRenderers = root.GetComponentsInChildren<SkinnedMeshRenderer> (true);
|
||||
|
||||
foreach (var snapshot in snapshots) {
|
||||
for (int i = 0; i < skinnedMeshRenderers.Length; i++) {
|
||||
if (skinnedMeshRenderers [i] != null) {
|
||||
if (skinnedMeshRenderers [i].name.Equals (snapshot.key)) {
|
||||
var skinnedMeshRenderer = skinnedMeshRenderers [i];
|
||||
|
||||
if (snapshot.vertices.Length > 0) {
|
||||
var bindPoses = new Matrix4x4[snapshot.boneMetadata.Length];
|
||||
|
||||
for (int j = 0; j < bindPoses.Length; j++) {
|
||||
bindPoses [j] = snapshot.boneMetadata [j].BindPose;
|
||||
}
|
||||
|
||||
//Note that we do not explicitly call recalculate bounds because (as per the manual) this is implicit in an
|
||||
//assignment to vertices whenever the vertex count changes from zero to non-zero.
|
||||
|
||||
var mesh = new Mesh ();
|
||||
|
||||
skinnedMeshRenderer.materials = snapshot.materials;
|
||||
|
||||
mesh.vertices = snapshot.vertices;
|
||||
mesh.normals = snapshot.normals;
|
||||
mesh.uv = snapshot.coords;
|
||||
mesh.boneWeights = snapshot.boneWeights;
|
||||
mesh.tangents = snapshot.tangents;
|
||||
mesh.subMeshCount = snapshot.indices.Length;
|
||||
mesh.bindposes = bindPoses;
|
||||
|
||||
for (int j = 0; j < snapshot.indices.Length; j++) {
|
||||
mesh.SetTriangles (snapshot.indices [j], j, false);
|
||||
}
|
||||
|
||||
mesh.UploadMeshData (true);
|
||||
|
||||
skinnedMeshRenderer.sharedMesh = mesh;
|
||||
} else {
|
||||
DestroyImmediate (skinnedMeshRenderer);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var forwardPassAgent = root.GetComponent<ForwardPassAgent> ();
|
||||
|
||||
if (forwardPassAgent == null)
|
||||
forwardPassAgent = root.AddComponent<ForwardPassAgent> ();
|
||||
|
||||
forwardPassAgent.Snapshot = snapshots;
|
||||
}
|
||||
|
||||
public static bool DetermineSlice (Hackable hackable, Vector3 pointInWorldSpace, ref string boneName, ref float rootTipProgression)
|
||||
{
|
||||
const int nothing = -1;
|
||||
|
||||
var severables = hackable.severables;
|
||||
|
||||
|
||||
//in progress to add an option to priorize certain body parts to slice
|
||||
//Transform [] temporalSeverables = new Transform [2];
|
||||
//for (var i = 0; i < temporalSeverables.Length; i++) {
|
||||
// temporalSeverables [i] = severables [i];
|
||||
//}
|
||||
|
||||
//severables = new Transform [temporalSeverables.Length];
|
||||
|
||||
//for (var i = 0; i < temporalSeverables.Length; i++) {
|
||||
// severables [i] = temporalSeverables [i];
|
||||
//}
|
||||
|
||||
//print (severables.Length);
|
||||
|
||||
|
||||
var indexByObject = new Dictionary<Transform, int> ();
|
||||
for (var i = 0; i < severables.Length; i++) {
|
||||
indexByObject [severables [i]] = i;
|
||||
}
|
||||
|
||||
var severablesInThreeSpace = new Vector3[severables.Length];
|
||||
for (var i = 0; i < severables.Length; i++) {
|
||||
severablesInThreeSpace [i] = severables [i].position;
|
||||
}
|
||||
|
||||
var deltas = new Vector3[severables.Length];
|
||||
for (var i = 0; i < severables.Length; i++) {
|
||||
deltas [i] = severablesInThreeSpace [i] - pointInWorldSpace;
|
||||
}
|
||||
|
||||
var mags = new float[severables.Length];
|
||||
for (var i = 0; i < severables.Length; i++) {
|
||||
mags [i] = deltas [i].magnitude;
|
||||
}
|
||||
|
||||
var indexOfNearestThing = nothing;
|
||||
var distanceToNearestThing = float.PositiveInfinity;
|
||||
for (var i = 0; i < severables.Length; i++) {
|
||||
if (mags [i] < distanceToNearestThing) {
|
||||
indexOfNearestThing = i;
|
||||
distanceToNearestThing = mags [i];
|
||||
}
|
||||
}
|
||||
|
||||
if (indexOfNearestThing != nothing) {
|
||||
var nearestThing = severables [indexOfNearestThing];
|
||||
|
||||
if (indexByObject.ContainsKey (nearestThing.parent)) {
|
||||
var parentIndex = indexByObject [nearestThing.parent];
|
||||
|
||||
var hereDelta = severablesInThreeSpace [indexOfNearestThing] - severablesInThreeSpace [parentIndex];
|
||||
|
||||
var touchDelta = pointInWorldSpace - severablesInThreeSpace [parentIndex];
|
||||
|
||||
//If the touch is closer to the parent than the severable is, than it's between them.
|
||||
//We'll use that and then use the root tip progression to slice just the right spot.
|
||||
if (touchDelta.magnitude < hereDelta.magnitude) {
|
||||
indexOfNearestThing = parentIndex;
|
||||
nearestThing = severables [indexOfNearestThing];
|
||||
}
|
||||
}
|
||||
|
||||
var childIndices = new List<int> ();
|
||||
|
||||
for (var i = 0; i < severables.Length; i++) {
|
||||
var candidate = severables [i];
|
||||
|
||||
if (candidate.parent == nearestThing) {
|
||||
childIndices.Add (i);
|
||||
}
|
||||
}
|
||||
|
||||
rootTipProgression = 0f;
|
||||
|
||||
if (childIndices.Count > 0) {
|
||||
var aggregatedChildPositions = Vector3.zero;
|
||||
|
||||
foreach (var i in childIndices) {
|
||||
aggregatedChildPositions += severablesInThreeSpace [i];
|
||||
}
|
||||
|
||||
var meanChildPosition = aggregatedChildPositions / childIndices.Count;
|
||||
|
||||
var alfa = (pointInWorldSpace - nearestThing.position).sqrMagnitude;
|
||||
var bravo = (pointInWorldSpace - meanChildPosition).sqrMagnitude;
|
||||
|
||||
rootTipProgression = Mathf.Clamp (alfa / bravo, 0.0f, 0.99f);
|
||||
}
|
||||
|
||||
boneName = nearestThing.name;
|
||||
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public void SeverByJoint (GameObject subject, string jointName, float rootTipProgression, Vector3? planeNormal)
|
||||
{
|
||||
//Sanity check: are we already slicing this?
|
||||
foreach (var extantState in jobStates) {
|
||||
if (ReferenceEquals (extantState.Specification.Subject, subject)) {
|
||||
//Debug.LogErrorFormat("Turbo Slicer was asked to slice '{0}' but this target is already enqueued.", subject.name);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
rootTipProgression = Mathf.Clamp01 (rootTipProgression);
|
||||
|
||||
//These here are in local space because they're only used to copy to the resultant meshes; they're not used
|
||||
//to transform the vertices. We expect a world-space slice input.
|
||||
|
||||
Hackable hackable = null;
|
||||
|
||||
{
|
||||
var hackables = subject.GetComponentsInChildren<Hackable> ();
|
||||
|
||||
if (hackables.Length > 0) {
|
||||
if (hackables.Length > 1) {
|
||||
Debug.LogWarning ("Limb Hacker found multiple slice configurations on object '" + subject.name + "'! Behavior is undefined.");
|
||||
}
|
||||
|
||||
hackable = hackables [0];
|
||||
} else {
|
||||
Debug.LogWarning ("Limb Hacker found no slice configuration on object '" + subject.name + "'.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
//We need information about which BONES are getting severed.
|
||||
var metadataByNodeName = new Dictionary<string, NodeMetadata> ();
|
||||
{
|
||||
var childTransformByName = new Dictionary<string, Transform> ();
|
||||
var parentKeyByKey = new Dictionary<string, string> ();
|
||||
|
||||
foreach (Transform t in GetConcatenatedHierarchy(subject.transform)) {
|
||||
childTransformByName [t.name] = t;
|
||||
|
||||
var parent = t.parent;
|
||||
|
||||
if (t == subject.transform)
|
||||
parent = null;
|
||||
|
||||
parentKeyByKey [t.name] = parent == null ? null : parent.name;
|
||||
}
|
||||
|
||||
var severedByChildName = new Dictionary<string, bool> ();
|
||||
{
|
||||
foreach (string childName in childTransformByName.Keys) {
|
||||
severedByChildName [childName] = childName.Equals (jointName);
|
||||
}
|
||||
|
||||
bool changesMade;
|
||||
do {
|
||||
changesMade = false;
|
||||
|
||||
foreach (string childKey in childTransformByName.Keys) {
|
||||
bool severed = severedByChildName [childKey];
|
||||
|
||||
if (severed)
|
||||
continue;
|
||||
|
||||
string parentKey = parentKeyByKey [childKey];
|
||||
|
||||
bool parentSevered;
|
||||
|
||||
if (severedByChildName.TryGetValue (parentKey, out parentSevered) == false)
|
||||
continue;
|
||||
|
||||
if (parentSevered) {
|
||||
severedByChildName [childKey] = true;
|
||||
|
||||
changesMade = true;
|
||||
}
|
||||
}
|
||||
} while (changesMade);
|
||||
}
|
||||
|
||||
foreach (var kvp in severedByChildName) {
|
||||
var t = childTransformByName [kvp.Key];
|
||||
var isConsideredSevered = kvp.Value;
|
||||
metadataByNodeName [kvp.Key] = new NodeMetadata (t, isConsideredSevered);
|
||||
}
|
||||
}
|
||||
|
||||
IEnumerable<MeshSnapshot> snapshots;
|
||||
var forwardPassAgent = subject.GetComponent<ForwardPassAgent> ();
|
||||
if (forwardPassAgent == null) {
|
||||
var snapshotBuilder = new List<MeshSnapshot> ();
|
||||
var skinnedMeshRenderers = subject.GetComponentsInChildren<SkinnedMeshRenderer> (true);
|
||||
foreach (var smr in skinnedMeshRenderers) {
|
||||
var mesh = smr.sharedMesh;
|
||||
|
||||
var boneMetadata = new BoneMetadata[smr.bones.Length];
|
||||
|
||||
var bones = smr.bones;
|
||||
var bindPoses = mesh.bindposes;
|
||||
|
||||
for (int i = 0; i < boneMetadata.Length; i++) {
|
||||
boneMetadata [i] = new BoneMetadata (i, bones [i].name, bindPoses [i]);
|
||||
}
|
||||
|
||||
int? infillIndex = null;
|
||||
if (hackable.infillMaterial != null) {
|
||||
var mats = smr.sharedMaterials;
|
||||
for (int i = 0; i < mats.Length; i++) {
|
||||
if (hackable.infillMaterial == mats [i]) {
|
||||
infillIndex = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
MeshSnapshot snapshot;
|
||||
|
||||
MeshSnapshot preloadedFragment;
|
||||
if (preloadedMeshes.TryGetValue (mesh.GetInstanceID (), out preloadedFragment)) {
|
||||
//The preloaded fragments are missing data which is particular to the SMR. We'll combine it with such data here.
|
||||
|
||||
snapshot = preloadedFragment.WithKey (smr.name).WithMaterials (smr.sharedMaterials).WithBoneMetadata (boneMetadata).WithInfillIndex (infillIndex);
|
||||
} else {
|
||||
var indices = new int[mesh.subMeshCount][];
|
||||
for (int i = 0; i < mesh.subMeshCount; i++) {
|
||||
indices [i] = mesh.GetIndices (i);
|
||||
}
|
||||
|
||||
snapshot = new MeshSnapshot (
|
||||
smr.name,
|
||||
mesh.vertices,
|
||||
mesh.normals,
|
||||
mesh.uv,
|
||||
mesh.tangents,
|
||||
mesh.boneWeights,
|
||||
smr.sharedMaterials,
|
||||
boneMetadata,
|
||||
infillIndex,
|
||||
indices);
|
||||
}
|
||||
|
||||
snapshotBuilder.Add (snapshot);
|
||||
}
|
||||
snapshots = snapshotBuilder;
|
||||
} else {
|
||||
snapshots = forwardPassAgent.Snapshot;
|
||||
}
|
||||
|
||||
var jobSpec = new JobSpecification (subject, hackable, snapshots, metadataByNodeName, hackable.infillMaterial, jointName, rootTipProgression, planeNormal, hackable.infillMode, true);
|
||||
var jobState = new JobState (jobSpec);
|
||||
|
||||
try {
|
||||
switch (workerThreadMode) {
|
||||
case WorkerThreadMode.Asynchronous:
|
||||
jobStates.Add (jobState);
|
||||
#if NETFX_CORE && !UNITY_EDITOR
|
||||
System.Threading.Tasks.Task.Factory.StartNew(ThreadSafeHack.Slice, jobState);
|
||||
#else
|
||||
System.Threading.ThreadPool.QueueUserWorkItem (ThreadSafeHack.Slice, jobState);
|
||||
#endif
|
||||
break;
|
||||
case WorkerThreadMode.Synchronous:
|
||||
ThreadSafeHack.Slice (jobState);
|
||||
if (jobState.HasYield) {
|
||||
ConsumeJobYield (jobState);
|
||||
} else if (jobState.HasException) {
|
||||
throw jobState.Exception;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
throw new System.NotImplementedException ();
|
||||
}
|
||||
} catch (System.Exception ex) {
|
||||
Debug.LogException (ex, subject);
|
||||
}
|
||||
}
|
||||
|
||||
void Update ()
|
||||
{
|
||||
jobStateRemovalQueue.Clear ();
|
||||
jobStateQueue.Clear ();
|
||||
jobStateQueue.AddRange (jobStates);
|
||||
foreach (var jobState in jobStateQueue) {
|
||||
if (jobState.IsDone) {
|
||||
try {
|
||||
if (jobState.HasYield) {
|
||||
ConsumeJobYield (jobState);
|
||||
} else if (jobState.HasException) {
|
||||
throw jobState.Exception;
|
||||
}
|
||||
} catch (System.Exception ex) {
|
||||
Debug.LogException (ex, jobState.Specification.Subject);
|
||||
|
||||
} finally {
|
||||
jobStateRemovalQueue.Add (jobState);
|
||||
}
|
||||
}
|
||||
}
|
||||
jobStates.ExceptWith (jobStateRemovalQueue);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
fileFormatVersion: 2
|
||||
guid: de80f123464224c8f923cc6be8e0d121
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 40995
|
||||
packageName: Game Kit Controller - Shooter Melee Adventure FPS TPS Creator 3D +
|
||||
2.5D
|
||||
packageVersion: 3.77h
|
||||
assetPath: Assets/Game Kit Controller/Integrations/LimbHacker-master/Guts/LimbHackerAgent.cs
|
||||
uploadId: 889948
|
||||
@@ -0,0 +1,86 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace NobleMuffins.LimbHacker.Guts
|
||||
{
|
||||
public class MeshSnapshot
|
||||
{
|
||||
public static readonly Vector4[] EmptyTangents = new Vector4[0];
|
||||
|
||||
public MeshSnapshot (string key,
|
||||
Vector3[] vertices, Vector3[] normals, Vector2[] coords, Vector4[] tangents, BoneWeight[] boneWeights,
|
||||
Material[] materials,
|
||||
BoneMetadata[] boneMetadata,
|
||||
int? infillIndex, int[][] indices)
|
||||
{
|
||||
this.key = key;
|
||||
this.vertices = vertices;
|
||||
this.normals = normals;
|
||||
this.coords = coords;
|
||||
this.tangents = tangents;
|
||||
this.materials = materials;
|
||||
this.boneMetadata = boneMetadata;
|
||||
this.boneWeights = boneWeights;
|
||||
this.infillIndex = infillIndex;
|
||||
this.indices = indices;
|
||||
}
|
||||
|
||||
public readonly string key;
|
||||
public readonly Vector3[] vertices;
|
||||
public readonly Vector3[] normals;
|
||||
public readonly Vector2[] coords;
|
||||
public readonly Vector4[] tangents;
|
||||
public readonly int? infillIndex;
|
||||
public readonly Material[] materials;
|
||||
public readonly BoneMetadata[] boneMetadata;
|
||||
public readonly BoneWeight[] boneWeights;
|
||||
|
||||
public readonly int[][] indices;
|
||||
|
||||
public MeshSnapshot WithKey(string figure)
|
||||
{
|
||||
return new MeshSnapshot(figure, vertices, normals, coords, tangents, boneWeights, materials, boneMetadata, infillIndex, indices);
|
||||
}
|
||||
|
||||
public MeshSnapshot WithInfillIndex(int? infillIndex)
|
||||
{
|
||||
return new MeshSnapshot(key, vertices, normals, coords, tangents, boneWeights, materials, boneMetadata, infillIndex, indices);
|
||||
}
|
||||
|
||||
public MeshSnapshot WithBoneMetadata(BoneMetadata[] figure)
|
||||
{
|
||||
return new MeshSnapshot(key, vertices, normals, coords, tangents, boneWeights, materials, figure, infillIndex, indices);
|
||||
}
|
||||
|
||||
public MeshSnapshot WithBoneWeights(BoneWeight[] figure)
|
||||
{
|
||||
return new MeshSnapshot(key, vertices, normals, coords, tangents, figure, materials, boneMetadata, infillIndex, indices);
|
||||
}
|
||||
|
||||
public MeshSnapshot WithMaterials(Material[] figure)
|
||||
{
|
||||
return new MeshSnapshot(key, vertices, normals, coords, tangents, boneWeights, figure, boneMetadata, infillIndex, indices);
|
||||
}
|
||||
|
||||
public MeshSnapshot WithVertices(Vector3[] figure) {
|
||||
return new MeshSnapshot(key, figure, normals, coords, tangents, boneWeights, materials, boneMetadata, infillIndex, indices);
|
||||
}
|
||||
|
||||
public MeshSnapshot WithNormals(Vector3[] figure) {
|
||||
return new MeshSnapshot(key, vertices, figure, coords, tangents, boneWeights, materials, boneMetadata, infillIndex, indices);
|
||||
}
|
||||
|
||||
public MeshSnapshot WithCoords(Vector2[] figure) {
|
||||
return new MeshSnapshot(key, vertices, normals, figure, tangents, boneWeights, materials, boneMetadata, infillIndex, indices);
|
||||
}
|
||||
|
||||
public MeshSnapshot WithTangents(Vector4[] figure) {
|
||||
return new MeshSnapshot(key, vertices, normals, coords, figure, boneWeights, materials, boneMetadata, infillIndex, indices);
|
||||
}
|
||||
|
||||
public MeshSnapshot WithIndices(int[][] figure)
|
||||
{
|
||||
return new MeshSnapshot(key, vertices, normals, coords, tangents, boneWeights, materials, boneMetadata, infillIndex, figure);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2a2fcf533779f87489f88e060941ef13
|
||||
timeCreated: 1487680054
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 40995
|
||||
packageName: Game Kit Controller - Shooter Melee Adventure FPS TPS Creator 3D +
|
||||
2.5D
|
||||
packageVersion: 3.77h
|
||||
assetPath: Assets/Game Kit Controller/Integrations/LimbHacker-master/Guts/MeshSnapshot.cs
|
||||
uploadId: 889948
|
||||
@@ -0,0 +1,222 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace NobleMuffins.LimbHacker.Guts
|
||||
{
|
||||
public static class MeshSnapshotExtensions
|
||||
{
|
||||
static readonly ArrayPool<int> intArrayPool = new ArrayPool<int>(4);
|
||||
static readonly ArrayPool<Vector3> vectorThreePool = new ArrayPool<Vector3>(4);
|
||||
|
||||
public static MeshSnapshot EmbraceAndExtend(this MeshSnapshot source,
|
||||
ArrayBuilder<Vector3> newVertices, ArrayBuilder<Vector3> newNormals, ArrayBuilder<Vector2> newCoords, ArrayBuilder<BoneWeight> newWeights, ArrayBuilder<int>[] newIndicesBySubmesh)
|
||||
{
|
||||
const int Unassigned = -1;
|
||||
|
||||
var vertexCount = newVertices.length;
|
||||
var submeshCount = newIndicesBySubmesh.Length;
|
||||
|
||||
int[] transferTable;
|
||||
using (intArrayPool.Get(vertexCount, false, out transferTable))
|
||||
{
|
||||
for (int i = 0; i < vertexCount; i++)
|
||||
{
|
||||
transferTable[i] = Unassigned;
|
||||
}
|
||||
|
||||
var targetIndex = 0;
|
||||
|
||||
var targetIndexArrays = new int[submeshCount][];
|
||||
|
||||
for (int submeshIndex = 0; submeshIndex < submeshCount; submeshIndex++)
|
||||
{
|
||||
var sourceIndices = newIndicesBySubmesh[submeshIndex];
|
||||
var targetIndices = targetIndexArrays[submeshIndex] = new int[sourceIndices.length];
|
||||
|
||||
for (int i = 0; i < sourceIndices.length; i++)
|
||||
{
|
||||
int requestedVertex = sourceIndices.array[i];
|
||||
|
||||
int j = transferTable[requestedVertex];
|
||||
|
||||
if (j == Unassigned)
|
||||
{
|
||||
j = targetIndex;
|
||||
transferTable[requestedVertex] = j;
|
||||
targetIndex++;
|
||||
}
|
||||
|
||||
targetIndices[i] = j;
|
||||
}
|
||||
}
|
||||
|
||||
var newVertexCount = targetIndex;
|
||||
|
||||
var targetVertices = new Vector3[newVertexCount];
|
||||
var targetCoords = new Vector2[newVertexCount];
|
||||
var targetNormals = new Vector3[newVertexCount];
|
||||
var boneWeights = new BoneWeight[newVertexCount];
|
||||
|
||||
for (int i = 0; i < vertexCount; i++)
|
||||
{
|
||||
int j = transferTable[i];
|
||||
if (j != Unassigned)
|
||||
{
|
||||
targetVertices[j] = newVertices.array[i];
|
||||
targetCoords[j] = newCoords.array[i];
|
||||
targetNormals[j] = newNormals.array[i];
|
||||
boneWeights[j] = newWeights.array[i];
|
||||
}
|
||||
}
|
||||
|
||||
Vector4[] targetTangents;
|
||||
|
||||
if (source.tangents.Length > 0)
|
||||
{
|
||||
//This code assumes that the new geometry is a proper superset of the old geometry.
|
||||
//But there is a catch; while new geometry is provided, new tangents are not.
|
||||
//So we source some tangents from the source data, but over that limit, we have to
|
||||
//generate them.
|
||||
|
||||
targetTangents = new Vector4[newVertexCount];
|
||||
|
||||
var newGeometryStartsFrom = source.vertices.Length;
|
||||
|
||||
for (int i = 0; i < newGeometryStartsFrom; i++)
|
||||
{
|
||||
int j = transferTable[i];
|
||||
if (j != Unassigned)
|
||||
{
|
||||
targetTangents[j] = source.tangents[i];
|
||||
}
|
||||
}
|
||||
|
||||
//Based on code here:
|
||||
//http://www.cs.upc.edu/~virtual/G/1.%20Teoria/06.%20Textures/Tangent%20Space%20Calculation.pdf
|
||||
|
||||
Vector3[] tan1, tan2;
|
||||
|
||||
using (vectorThreePool.Get(vertexCount, true, out tan1))
|
||||
using (vectorThreePool.Get(vertexCount, true, out tan2))
|
||||
{
|
||||
for (int i = 0; i < newIndicesBySubmesh.Length; i++)
|
||||
{
|
||||
var triangles = newIndicesBySubmesh[i];
|
||||
|
||||
for (int j = 0; j < triangles.length;)
|
||||
{
|
||||
var j1 = triangles.array[j++];
|
||||
var j2 = triangles.array[j++];
|
||||
var j3 = triangles.array[j++];
|
||||
|
||||
Debug.Assert(j1 != j2 && j1 != j3);
|
||||
|
||||
var isRelevant = j1 >= newGeometryStartsFrom || j2 >= newGeometryStartsFrom || j3 >= newGeometryStartsFrom;
|
||||
|
||||
if (isRelevant)
|
||||
{
|
||||
var v1 = newVertices.array[j1];
|
||||
var v2 = newVertices.array[j2];
|
||||
var v3 = newVertices.array[j3];
|
||||
|
||||
//We have to test for degeneracy.
|
||||
var e1 = v1 - v2;
|
||||
var e2 = v1 - v3;
|
||||
const float epsilon = 1.0f / 65536.0f;
|
||||
if (e1.sqrMagnitude > epsilon && e2.sqrMagnitude > epsilon)
|
||||
{
|
||||
var w1 = newCoords.array[j1];
|
||||
var w2 = newCoords.array[j2];
|
||||
var w3 = newCoords.array[j3];
|
||||
|
||||
var x1 = v2.x - v1.x;
|
||||
var x2 = v3.x - v1.x;
|
||||
var y1 = v2.y - v1.y;
|
||||
var y2 = v3.y - v1.y;
|
||||
var z1 = v2.z - v1.z;
|
||||
var z2 = v3.z - v1.z;
|
||||
|
||||
var s1 = w2.x - w1.x;
|
||||
var s2 = w3.x - w1.x;
|
||||
var t1 = w2.y - w1.y;
|
||||
var t2 = w3.y - w1.y;
|
||||
|
||||
var r = 1.0f / (s1 * t2 - s2 * t1);
|
||||
|
||||
var sX = (t2 * x1 - t1 * x2) * r;
|
||||
var sY = (t2 * y1 - t1 * y2) * r;
|
||||
var sZ = (t2 * z1 - t1 * z2) * r;
|
||||
|
||||
var tX = (s1 * x2 - s2 * x1) * r;
|
||||
var tY = (s1 * y2 - s2 * y1) * r;
|
||||
var tZ = (s1 * z2 - s2 * z1) * r;
|
||||
|
||||
var tan1j1 = tan1[j1];
|
||||
var tan1j2 = tan1[j2];
|
||||
var tan1j3 = tan1[j3];
|
||||
var tan2j1 = tan2[j1];
|
||||
var tan2j2 = tan2[j2];
|
||||
var tan2j3 = tan2[j3];
|
||||
|
||||
tan1j1.x += sX;
|
||||
tan1j1.y += sY;
|
||||
tan1j1.z += sZ;
|
||||
tan1j2.x += sX;
|
||||
tan1j2.y += sY;
|
||||
tan1j2.z += sZ;
|
||||
tan1j3.x += sX;
|
||||
tan1j3.y += sY;
|
||||
tan1j3.z += sZ;
|
||||
|
||||
tan2j1.x += tX;
|
||||
tan2j1.y += tY;
|
||||
tan2j1.z += tZ;
|
||||
tan2j2.x += tX;
|
||||
tan2j2.y += tY;
|
||||
tan2j2.z += tZ;
|
||||
tan2j3.x += tX;
|
||||
tan2j3.y += tY;
|
||||
tan2j3.z += tZ;
|
||||
|
||||
tan1[j1] = tan1j1;
|
||||
tan1[j2] = tan1j2;
|
||||
tan1[j3] = tan1j3;
|
||||
tan2[j1] = tan2j1;
|
||||
tan2[j2] = tan2j2;
|
||||
tan2[j3] = tan2j3;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = newGeometryStartsFrom; i < vertexCount; i++)
|
||||
{
|
||||
int j = transferTable[i];
|
||||
if (j != Unassigned)
|
||||
{
|
||||
var n = newNormals.array[i];
|
||||
var t = tan1[i];
|
||||
|
||||
// Gram-Schmidt orthogonalize
|
||||
Vector3.OrthoNormalize(ref n, ref t);
|
||||
|
||||
targetTangents[j].x = t.x;
|
||||
targetTangents[j].y = t.y;
|
||||
targetTangents[j].z = t.z;
|
||||
|
||||
// Calculate handedness
|
||||
targetTangents[j].w = (Vector3.Dot(Vector3.Cross(n, t), tan2[i]) < 0.0f) ? -1.0f : 1.0f;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
targetTangents = new Vector4[0];
|
||||
}
|
||||
|
||||
return new MeshSnapshot(source.key, targetVertices, targetNormals, targetCoords, targetTangents, boneWeights, source.materials, source.boneMetadata, source.infillIndex, targetIndexArrays);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bc10464e1f6124caabecddd5f2cbc484
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 40995
|
||||
packageName: Game Kit Controller - Shooter Melee Adventure FPS TPS Creator 3D +
|
||||
2.5D
|
||||
packageVersion: 3.77h
|
||||
assetPath: Assets/Game Kit Controller/Integrations/LimbHacker-master/Guts/MeshSnapshotExtensions.cs
|
||||
uploadId: 889948
|
||||
@@ -0,0 +1,8 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace NobleMuffins.LimbHacker.Guts
|
||||
{ public class MuffinSliceCommon
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d055ba6864e784455963562b3f3850b9
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 40995
|
||||
packageName: Game Kit Controller - Shooter Melee Adventure FPS TPS Creator 3D +
|
||||
2.5D
|
||||
packageVersion: 3.77h
|
||||
assetPath: Assets/Game Kit Controller/Integrations/LimbHacker-master/Guts/MuffinSliceCommon.cs
|
||||
uploadId: 889948
|
||||
@@ -0,0 +1,39 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace NobleMuffins.LimbHacker.Guts
|
||||
{
|
||||
public class NodeMetadata
|
||||
{
|
||||
public NodeMetadata(Transform t, bool isConsideredSevered)
|
||||
{
|
||||
Key = t.name;
|
||||
LocalPosition = t.localPosition;
|
||||
LocalScale = t.localScale;
|
||||
LocalRotation = t.localRotation;
|
||||
IsActive = t.gameObject.activeSelf;
|
||||
IsConsideredSevered = isConsideredSevered;
|
||||
WorldToLocalMatrix = t.worldToLocalMatrix;
|
||||
var parent = t.parent;
|
||||
if (parent != null)
|
||||
{
|
||||
ParentKey = parent.name;
|
||||
}
|
||||
}
|
||||
|
||||
public string Key { get; private set; }
|
||||
|
||||
public string ParentKey { get; private set; }
|
||||
|
||||
public bool IsActive { get; private set; }
|
||||
|
||||
public bool IsConsideredSevered { get; private set; }
|
||||
|
||||
public Vector3 LocalPosition { get; private set; }
|
||||
|
||||
public Vector3 LocalScale { get; private set; }
|
||||
|
||||
public Quaternion LocalRotation { get; private set; }
|
||||
|
||||
public Matrix4x4 WorldToLocalMatrix { get; private set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 67cd896e322c7e1488de705a1c5d68aa
|
||||
timeCreated: 1488378947
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 40995
|
||||
packageName: Game Kit Controller - Shooter Melee Adventure FPS TPS Creator 3D +
|
||||
2.5D
|
||||
packageVersion: 3.77h
|
||||
assetPath: Assets/Game Kit Controller/Integrations/LimbHacker-master/Guts/NodeMetadata.cs
|
||||
uploadId: 889948
|
||||
@@ -0,0 +1,22 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace NobleMuffins.LimbHacker.Guts
|
||||
{
|
||||
public class SliceEventArgs: EventArgs
|
||||
{
|
||||
public SliceEventArgs (Plane planeInWorldSpace, Vector3 focalPointInWorldSpace, GameObject[] parts): base()
|
||||
{
|
||||
PlaneInWorldSpace = planeInWorldSpace;
|
||||
FocalPointInWorldSpace = focalPointInWorldSpace;
|
||||
Parts = parts;
|
||||
}
|
||||
|
||||
public Plane PlaneInWorldSpace { get; private set; }
|
||||
|
||||
public Vector3 FocalPointInWorldSpace { get; private set; }
|
||||
|
||||
public GameObject[] Parts { get; private set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bbf92aea741bf89468f561d9027513cd
|
||||
timeCreated: 1487677297
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 40995
|
||||
packageName: Game Kit Controller - Shooter Melee Adventure FPS TPS Creator 3D +
|
||||
2.5D
|
||||
packageVersion: 3.77h
|
||||
assetPath: Assets/Game Kit Controller/Integrations/LimbHacker-master/Guts/SliceEventArgs.cs
|
||||
uploadId: 889948
|
||||
@@ -0,0 +1,139 @@
|
||||
using UnityEngine;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace NobleMuffins.LimbHacker.Guts
|
||||
{
|
||||
public class Slicer : MonoBehaviour
|
||||
{
|
||||
class PendingSlice
|
||||
{
|
||||
public PendingSlice (Vector3 _point, ISliceable _target)
|
||||
{
|
||||
point = _point;
|
||||
target = _target;
|
||||
}
|
||||
|
||||
public readonly Vector3 point;
|
||||
public readonly ISliceable target;
|
||||
}
|
||||
|
||||
public Transform planeDefiner1, planeDefiner2, planeDefiner3;
|
||||
public MeshRenderer editorVisualization;
|
||||
|
||||
private readonly Queue<PendingSlice> pendingSlices = new Queue<PendingSlice> ();
|
||||
|
||||
// Use this for initialization
|
||||
void Start ()
|
||||
{
|
||||
if (editorVisualization != null) {
|
||||
editorVisualization.enabled = false;
|
||||
}
|
||||
|
||||
bool hasAllPlaneDefiners = true;
|
||||
|
||||
hasAllPlaneDefiners = planeDefiner1 != null;
|
||||
hasAllPlaneDefiners &= planeDefiner2 != null;
|
||||
hasAllPlaneDefiners &= planeDefiner3 != null;
|
||||
|
||||
if (hasAllPlaneDefiners == false) {
|
||||
Debug.LogError ("Slicer '" + gameObject.name + "' is missing a plane definer!");
|
||||
}
|
||||
}
|
||||
|
||||
private List<GameObject> suppressUntilContactCeases = new List<GameObject> ();
|
||||
|
||||
void OnTriggerEnter (Collider other)
|
||||
{
|
||||
if (suppressUntilContactCeases.Contains (other.gameObject) == false) {
|
||||
ISliceable sliceable = other.GetComponent (typeof(ISliceable)) as ISliceable;
|
||||
|
||||
if (sliceable != null) {
|
||||
Vector3 point = other.ClosestPointOnBounds (positionInWorldSpace);
|
||||
|
||||
pendingSlices.Enqueue (new PendingSlice (point, sliceable));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void OnTriggerExit (Collider other)
|
||||
{
|
||||
ContactCeased (other.gameObject);
|
||||
}
|
||||
|
||||
void OnCollisionEnter (Collision other)
|
||||
{
|
||||
if (suppressUntilContactCeases.Contains (other.gameObject) == false) {
|
||||
ISliceable sliceable = other.gameObject.GetComponent (typeof(ISliceable)) as ISliceable;
|
||||
|
||||
if (sliceable != null) {
|
||||
Vector3 point = other.contacts [0].point;
|
||||
|
||||
pendingSlices.Enqueue (new PendingSlice (point, sliceable));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void OnCollisionExit (Collision other)
|
||||
{
|
||||
ContactCeased (other.gameObject);
|
||||
}
|
||||
|
||||
private void ContactCeased (GameObject other)
|
||||
{
|
||||
if (suppressUntilContactCeases.Contains (other)) {
|
||||
suppressUntilContactCeases.Remove (other);
|
||||
}
|
||||
}
|
||||
|
||||
private Vector3 positionInWorldSpace {
|
||||
get {
|
||||
return (planeDefiner1.position + planeDefiner2.position + planeDefiner3.position) / 3f;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private Vector3 normalInWorldSpace {
|
||||
get {
|
||||
Vector3 t0 = planeDefiner1.position;
|
||||
Vector3 t1 = planeDefiner2.position;
|
||||
Vector3 t2 = planeDefiner3.position;
|
||||
|
||||
Vector3 v;
|
||||
|
||||
v.x = t0.y * (t1.z - t2.z) + t1.y * (t2.z - t0.z) + t2.y * (t0.z - t1.z);
|
||||
v.y = t0.z * (t1.x - t2.x) + t1.z * (t2.x - t0.x) + t2.z * (t0.x - t1.x);
|
||||
v.z = t0.x * (t1.y - t2.y) + t1.x * (t2.y - t0.y) + t2.x * (t0.y - t1.y);
|
||||
|
||||
return v;
|
||||
}
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void LateUpdate ()
|
||||
{
|
||||
while (pendingSlices.Count > 0) {
|
||||
PendingSlice pendingSlice = pendingSlices.Dequeue ();
|
||||
|
||||
var component = pendingSlice.target as MonoBehaviour;
|
||||
|
||||
if (component != null) {
|
||||
var targetGameObject = component.gameObject;
|
||||
|
||||
if (suppressUntilContactCeases.Contains (targetGameObject) == false) {
|
||||
|
||||
pendingSlice.target.Sliced += PendingSlice_target_Sliced;
|
||||
|
||||
pendingSlice.target.Slice (pendingSlice.point, normalInWorldSpace);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void PendingSlice_target_Sliced (object sender, SliceEventArgs e)
|
||||
{
|
||||
if (e.Parts.Length > 1) {
|
||||
suppressUntilContactCeases.AddRange (e.Parts);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5ba7232e00b07426ca2622a6eb88f648
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 40995
|
||||
packageName: Game Kit Controller - Shooter Melee Adventure FPS TPS Creator 3D +
|
||||
2.5D
|
||||
packageVersion: 3.77h
|
||||
assetPath: Assets/Game Kit Controller/Integrations/LimbHacker-master/Guts/Slicer.cs
|
||||
uploadId: 889948
|
||||
@@ -0,0 +1,41 @@
|
||||
namespace NobleMuffins.LimbHacker.Guts
|
||||
{
|
||||
struct SplitAction
|
||||
{
|
||||
public const int nullIndex = -1;
|
||||
|
||||
public const int TO_ALFA = 0x01, TO_BRAVO = 0x02, INTERSECT = 0x04;
|
||||
|
||||
public int flags; //1
|
||||
public int cloneOf;
|
||||
public int index0, index1, realIndex; //4 * 4 = 16 bytes
|
||||
public float intersectionResult; //4 bytes
|
||||
|
||||
public SplitAction(bool _toFront, bool _toBack, int _index0)
|
||||
{
|
||||
flags = 0;
|
||||
if (_toFront) flags = flags | TO_ALFA;
|
||||
if (_toBack) flags = flags | TO_BRAVO;
|
||||
index0 = _index0;
|
||||
index1 = nullIndex;
|
||||
cloneOf = nullIndex;
|
||||
realIndex = index0;
|
||||
intersectionResult = 0f;
|
||||
}
|
||||
|
||||
public SplitAction(int _index0, int _index1)
|
||||
{
|
||||
flags = TO_ALFA | TO_BRAVO | INTERSECT;
|
||||
index0 = _index0;
|
||||
index1 = _index1;
|
||||
cloneOf = nullIndex;
|
||||
realIndex = nullIndex;
|
||||
intersectionResult = 0f;
|
||||
}
|
||||
|
||||
public new string ToString()
|
||||
{
|
||||
return string.Format("SplitAction: Geometry={1}", realIndex);
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fd34f97c27255af4b89bc97535d5342e
|
||||
timeCreated: 1488536764
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 40995
|
||||
packageName: Game Kit Controller - Shooter Melee Adventure FPS TPS Creator 3D +
|
||||
2.5D
|
||||
packageVersion: 3.77h
|
||||
assetPath: Assets/Game Kit Controller/Integrations/LimbHacker-master/Guts/SplitAction.cs
|
||||
uploadId: 889948
|
||||
@@ -0,0 +1,9 @@
|
||||
namespace NobleMuffins.LimbHacker.Guts
|
||||
{
|
||||
public enum WorkerThreadMode
|
||||
{
|
||||
Asynchronous,
|
||||
Synchronous
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cad3ac0a785962949a2b9584496c97ac
|
||||
timeCreated: 1487680054
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 40995
|
||||
packageName: Game Kit Controller - Shooter Melee Adventure FPS TPS Creator 3D +
|
||||
2.5D
|
||||
packageVersion: 3.77h
|
||||
assetPath: Assets/Game Kit Controller/Integrations/LimbHacker-master/Guts/ThreadMode.cs
|
||||
uploadId: 889948
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,20 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 92a0d7a929b598f47aa39e97e3ef6a56
|
||||
timeCreated: 1487679864
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 40995
|
||||
packageName: Game Kit Controller - Shooter Melee Adventure FPS TPS Creator 3D +
|
||||
2.5D
|
||||
packageVersion: 3.77h
|
||||
assetPath: Assets/Game Kit Controller/Integrations/LimbHacker-master/Guts/ThreadSafeHack.cs
|
||||
uploadId: 889948
|
||||
@@ -0,0 +1,156 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace NobleMuffins.LimbHacker.Guts
|
||||
{
|
||||
static class Triangulation
|
||||
{
|
||||
const float Epsilon = float.Epsilon;
|
||||
|
||||
private static float Area(Vector2[] contour, int length)
|
||||
{
|
||||
int n = length;
|
||||
|
||||
float A=0.0f;
|
||||
|
||||
for(int p=n-1,q=0; q<n; p=q++)
|
||||
{
|
||||
A+= contour[p].x*contour[q].y - contour[q].x*contour[p].y;
|
||||
}
|
||||
return A*0.5f;
|
||||
}
|
||||
|
||||
/*
|
||||
InsideTriangle decides if a point P is Inside of the triangle
|
||||
defined by A, B, C.
|
||||
*/
|
||||
private static bool InsideTriangle(float Ax, float Ay,
|
||||
float Bx, float By,
|
||||
float Cx, float Cy,
|
||||
float Px, float Py)
|
||||
{
|
||||
float ax, ay, bx, by, cx, cy, apx, apy, bpx, bpy, cpx, cpy;
|
||||
float cCROSSap, bCROSScp, aCROSSbp;
|
||||
|
||||
ax = Cx - Bx; ay = Cy - By;
|
||||
bx = Ax - Cx; by = Ay - Cy;
|
||||
cx = Bx - Ax; cy = By - Ay;
|
||||
apx= Px - Ax; apy= Py - Ay;
|
||||
bpx= Px - Bx; bpy= Py - By;
|
||||
cpx= Px - Cx; cpy= Py - Cy;
|
||||
|
||||
aCROSSbp = ax*bpy - ay*bpx;
|
||||
cCROSSap = cx*apy - cy*apx;
|
||||
bCROSScp = bx*cpy - by*cpx;
|
||||
|
||||
return ((aCROSSbp >= 0.0f) && (bCROSScp >= 0.0f) && (cCROSSap >= 0.0f));
|
||||
}
|
||||
|
||||
private static bool Snip(Vector2[] contour,int u,int v,int w,int n,int[] V)
|
||||
{
|
||||
int p;
|
||||
float Ax, Ay, Bx, By, Cx, Cy, Px, Py;
|
||||
|
||||
Ax = contour[V[u]].x;
|
||||
Ay = contour[V[u]].y;
|
||||
|
||||
Bx = contour[V[v]].x;
|
||||
By = contour[V[v]].y;
|
||||
|
||||
Cx = contour[V[w]].x;
|
||||
Cy = contour[V[w]].y;
|
||||
|
||||
if ( Epsilon > (((Bx-Ax)*(Cy-Ay)) - ((By-Ay)*(Cx-Ax))) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
for (p=0;p<n;p++)
|
||||
{
|
||||
if( (p == u) || (p == v) || (p == w) ) continue;
|
||||
|
||||
Px = contour[V[p]].x;
|
||||
Py = contour[V[p]].y;
|
||||
|
||||
if (InsideTriangle(Ax,Ay,Bx,By,Cx,Cy,Px,Py))
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static int GetArraySize(int length) {
|
||||
//Given that the contour features n vertices, the result is expected to feature n - 2 triangles.
|
||||
return System.Math.Max( 0, (length - 2) * 3 );
|
||||
}
|
||||
|
||||
public static bool Triangulate(Vector2[] contour, int length, int[] result)
|
||||
{
|
||||
/* allocate and initialize list of Vertices in polygon */
|
||||
|
||||
int n = length;
|
||||
if ( n < 3 ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var expectedVertexCount = GetArraySize(length);
|
||||
|
||||
if(result.Length < expectedVertexCount) {
|
||||
throw new System.ArgumentException();
|
||||
}
|
||||
|
||||
int[] V = new int[n];
|
||||
|
||||
/* we want a counter-clockwise polygon in V */
|
||||
|
||||
if ( 0.0f < Area(contour, length) )
|
||||
for (int v=0; v<n; v++) V[v] = v;
|
||||
else
|
||||
for(int v=0; v<n; v++) V[v] = (n-1)-v;
|
||||
|
||||
int nv = n;
|
||||
|
||||
/* remove nv-2 Vertices, creating 1 triangle every time */
|
||||
int count = 2*nv; /* error detection */
|
||||
|
||||
int resultIndex = 0;
|
||||
|
||||
for(int m=0, v=nv-1; nv>2; )
|
||||
{
|
||||
/* if we loop, it is probably a non-simple polygon */
|
||||
if (0 >= (count--))
|
||||
{
|
||||
//** Triangulate: ERROR - probable bad polygon!
|
||||
return false;
|
||||
}
|
||||
|
||||
/* three consecutive vertices in current polygon, <u,v,w> */
|
||||
int u = v ; if (nv <= u) u = 0; /* previous */
|
||||
v = u+1; if (nv <= v) v = 0; /* new v */
|
||||
int w = v+1; if (nv <= w) w = 0; /* next */
|
||||
|
||||
if ( Snip(contour,u,v,w,nv,V) )
|
||||
{
|
||||
int a,b,c,s,t;
|
||||
|
||||
/* true names of the vertices */
|
||||
a = V[u]; b = V[v]; c = V[w];
|
||||
|
||||
/* output Triangle */
|
||||
result[resultIndex++] = a;
|
||||
result[resultIndex++] = b;
|
||||
result[resultIndex++] = c;
|
||||
|
||||
m++;
|
||||
|
||||
/* remove v from remaining polygon */
|
||||
for(s=v,t=v+1;t<nv;s++,t++) V[s] = V[t]; nv--;
|
||||
|
||||
/* resest error detection counter */
|
||||
count = 2*nv;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4addc83a25b0a1f4a877be6db3b15cf9
|
||||
timeCreated: 1488541520
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 40995
|
||||
packageName: Game Kit Controller - Shooter Melee Adventure FPS TPS Creator 3D +
|
||||
2.5D
|
||||
packageVersion: 3.77h
|
||||
assetPath: Assets/Game Kit Controller/Integrations/LimbHacker-master/Guts/Triangulation.cs
|
||||
uploadId: 889948
|
||||
@@ -0,0 +1,55 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace NobleMuffins.LimbHacker.Guts
|
||||
{
|
||||
public static class VectorExtensions
|
||||
{
|
||||
public static Vector3 ClampNormalToBicone(this Vector3 normal, Vector3 axis, float maximumDegrees)
|
||||
{
|
||||
var minimumDotProduct = Mathf.Cos(maximumDegrees * Mathf.Deg2Rad);
|
||||
|
||||
var dotProduct = Vector3.Dot(normal, axis);
|
||||
|
||||
var result = normal;
|
||||
|
||||
if (Mathf.Abs(dotProduct) < minimumDotProduct)
|
||||
{
|
||||
var sign = Mathf.Sign(dotProduct);
|
||||
|
||||
var differenceBetweenNowAndIdeal = minimumDotProduct - Mathf.Abs(dotProduct);
|
||||
|
||||
var repairativeContribution = axis * differenceBetweenNowAndIdeal * sign;
|
||||
|
||||
var currentCorrective = 1f;
|
||||
|
||||
var lowCorrective = 1f;
|
||||
var highCorrective = 100f;
|
||||
|
||||
var iterations = 16;
|
||||
|
||||
while (iterations > 0)
|
||||
{
|
||||
result = (normal + repairativeContribution * currentCorrective).normalized;
|
||||
|
||||
float dp = Mathf.Abs(Vector3.Dot(result, axis));
|
||||
|
||||
if (dp > minimumDotProduct)
|
||||
{
|
||||
highCorrective = currentCorrective;
|
||||
currentCorrective = (currentCorrective + lowCorrective) / 2f;
|
||||
}
|
||||
else if (dp < minimumDotProduct)
|
||||
{
|
||||
lowCorrective = currentCorrective;
|
||||
currentCorrective = (currentCorrective + highCorrective) / 2f;
|
||||
}
|
||||
|
||||
iterations--;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 491f449ce30944f42873da6a16c0fbef
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 40995
|
||||
packageName: Game Kit Controller - Shooter Melee Adventure FPS TPS Creator 3D +
|
||||
2.5D
|
||||
packageVersion: 3.77h
|
||||
assetPath: Assets/Game Kit Controller/Integrations/LimbHacker-master/Guts/VectorExtensions.cs
|
||||
uploadId: 889948
|
||||
@@ -0,0 +1,31 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace NobleMuffins.LimbHacker.Guts
|
||||
{
|
||||
public class VectorMeanBuilder
|
||||
{
|
||||
private Vector3 aggregatedFigures = Vector3.zero;
|
||||
private int count = 0;
|
||||
|
||||
public void Add(Vector3 v)
|
||||
{
|
||||
aggregatedFigures += v;
|
||||
count++;
|
||||
}
|
||||
|
||||
public Vector3 Mean {
|
||||
get {
|
||||
if(count == 0)
|
||||
{
|
||||
return Vector3.zero;
|
||||
}
|
||||
else
|
||||
{
|
||||
float f = (float) count;
|
||||
|
||||
return aggregatedFigures / f;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 29e2c390c19f840748c7946a76c51815
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 40995
|
||||
packageName: Game Kit Controller - Shooter Melee Adventure FPS TPS Creator 3D +
|
||||
2.5D
|
||||
packageVersion: 3.77h
|
||||
assetPath: Assets/Game Kit Controller/Integrations/LimbHacker-master/Guts/VectorMeanBuilder.cs
|
||||
uploadId: 889948
|
||||
BIN
Assets/Game Kit Controller/Integrations/LimbHacker-master/Guts/sliceMesh.fbx
LFS
Normal file
BIN
Assets/Game Kit Controller/Integrations/LimbHacker-master/Guts/sliceMesh.fbx
LFS
Normal file
Binary file not shown.
@@ -0,0 +1,80 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6aaa3bac4819a47a4a7f81cab803b77e
|
||||
ModelImporter:
|
||||
serializedVersion: 15
|
||||
fileIDToRecycleName:
|
||||
100000: PlaneDefinition1
|
||||
100002: PlaneDefinition2
|
||||
100004: PlaneDefinition3
|
||||
100006: //RootNode
|
||||
100008: Visualization
|
||||
400000: PlaneDefinition1
|
||||
400002: PlaneDefinition2
|
||||
400004: PlaneDefinition3
|
||||
400006: //RootNode
|
||||
400008: Visualization
|
||||
2300000: Visualization
|
||||
3300000: Visualization
|
||||
4300000: Visualization
|
||||
7400000: Default Take
|
||||
11100000: //RootNode
|
||||
materials:
|
||||
importMaterials: 0
|
||||
materialName: 0
|
||||
materialSearch: 1
|
||||
animations:
|
||||
legacyGenerateAnimations: 4
|
||||
bakeSimulation: 0
|
||||
animationCompression: 1
|
||||
animationRotationError: .5
|
||||
animationPositionError: .5
|
||||
animationScaleError: .5
|
||||
animationWrapMode: 0
|
||||
clipAnimations: []
|
||||
isReadable: 1
|
||||
meshes:
|
||||
lODScreenPercentages: []
|
||||
globalScale: 1
|
||||
meshCompression: 3
|
||||
addColliders: 0
|
||||
importBlendShapes: 1
|
||||
swapUVChannels: 0
|
||||
generateSecondaryUV: 0
|
||||
useFileUnits: 1
|
||||
optimizeMeshForGPU: 1
|
||||
weldVertices: 1
|
||||
secondaryUVAngleDistortion: 8
|
||||
secondaryUVAreaDistortion: 15.000001
|
||||
secondaryUVHardAngle: 88
|
||||
secondaryUVPackMargin: 4
|
||||
tangentSpace:
|
||||
normalSmoothAngle: 60
|
||||
splitTangentsAcrossUV: 1
|
||||
normalImportMode: 2
|
||||
tangentImportMode: 2
|
||||
importAnimation: 1
|
||||
copyAvatar: 0
|
||||
humanDescription:
|
||||
human: []
|
||||
skeleton: []
|
||||
handles: []
|
||||
armTwist: .5
|
||||
foreArmTwist: .5
|
||||
upperLegTwist: .5
|
||||
legTwist: .5
|
||||
armStretch: .0500000007
|
||||
legStretch: .0500000007
|
||||
feetSpacing: 0
|
||||
rootMotionBoneName:
|
||||
lastHumanDescriptionAvatarSource: {instanceID: 0}
|
||||
additionalBone: 1
|
||||
animationType: 0
|
||||
userData:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 40995
|
||||
packageName: Game Kit Controller - Shooter Melee Adventure FPS TPS Creator 3D +
|
||||
2.5D
|
||||
packageVersion: 3.77h
|
||||
assetPath: Assets/Game Kit Controller/Integrations/LimbHacker-master/Guts/sliceMesh.fbx
|
||||
uploadId: 889948
|
||||
@@ -0,0 +1,28 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!21 &2100000
|
||||
Material:
|
||||
serializedVersion: 6
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_Name: slicerVisualizationMat
|
||||
m_Shader: {fileID: 10752, guid: 0000000000000000f000000000000000, type: 0}
|
||||
m_ShaderKeywords:
|
||||
m_LightmapFlags: 5
|
||||
m_CustomRenderQueue: -1
|
||||
stringTagMap: {}
|
||||
m_SavedProperties:
|
||||
serializedVersion: 2
|
||||
m_TexEnvs:
|
||||
- first:
|
||||
name: _MainTex
|
||||
second:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
m_Floats: []
|
||||
m_Colors:
|
||||
- first:
|
||||
name: _Color
|
||||
second: {r: 1, g: 1, b: 1, a: 1}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 43ee76a06b58342a0a7fc70cda423de8
|
||||
NativeFormatImporter:
|
||||
userData:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 40995
|
||||
packageName: Game Kit Controller - Shooter Melee Adventure FPS TPS Creator 3D +
|
||||
2.5D
|
||||
packageVersion: 3.77h
|
||||
assetPath: Assets/Game Kit Controller/Integrations/LimbHacker-master/Guts/slicerVisualizationMat.mat
|
||||
uploadId: 889948
|
||||
Reference in New Issue
Block a user