添加插件

This commit is contained in:
2025-11-10 00:08:26 +08:00
parent 4059c207c0
commit 76f80db694
2814 changed files with 436400 additions and 178 deletions

View File

@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: e56c9feb62e6b4f9ea6517ebb106419b
folderAsset: yes
timeCreated: 1503483313
licenseType: Store
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,48 @@
using System;
using UnityEngine;
namespace Obi{
public class ObiBoxShapeTracker2D : ObiShapeTracker
{
public ObiBoxShapeTracker2D(ObiCollider2D source, BoxCollider2D collider){
this.source = source;
this.collider = collider;
}
public override void UpdateIfNeeded (){
BoxCollider2D box = collider as BoxCollider2D;
var world = ObiColliderWorld.GetInstance();
int index = source.Handle.index;
// update collider:
var shape = world.colliderShapes[index];
shape.is2D = true;
shape.type = ColliderShape.ShapeType.Box;
shape.filter = source.Filter;
shape.SetSign(source.Inverted);
shape.isTrigger = box.isTrigger;
shape.rigidbodyIndex = source.Rigidbody != null ? source.Rigidbody.Handle.index : -1;
shape.materialIndex = source.CollisionMaterial != null ? source.CollisionMaterial.handle.index : -1;
shape.forceZoneIndex = source.ForceZone != null ? source.ForceZone.Handle.index : -1;
shape.contactOffset = source.Thickness + box.edgeRadius;
shape.center = box.offset;
shape.size = box.size;
world.colliderShapes[index] = shape;
// update bounds:
var aabb = world.colliderAabbs[index];
aabb.FromBounds(box.bounds, shape.contactOffset, true);
world.colliderAabbs[index] = aabb;
// update transform:
var trfm = world.colliderTransforms[index];
trfm.FromTransform2D(box.transform, source.Rigidbody as ObiRigidbody2D);
world.colliderTransforms[index] = trfm;
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: e3701e56c1528404daa61e704345b750
timeCreated: 1501960568
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,53 @@
using System;
using UnityEngine;
namespace Obi{
public class ObiCapsuleShapeTracker2D : ObiShapeTracker
{
public ObiCapsuleShapeTracker2D(ObiCollider2D source, CapsuleCollider2D collider)
{
this.source = source;
this.collider = collider;
}
public override void UpdateIfNeeded ()
{
CapsuleCollider2D capsule = collider as CapsuleCollider2D;
// retrieve collision world and index:
var world = ObiColliderWorld.GetInstance();
int index = source.Handle.index;
// update collider:
var shape = world.colliderShapes[index];
shape.is2D = true;
shape.type = ColliderShape.ShapeType.Capsule;
shape.filter = source.Filter;
shape.SetSign(source.Inverted);
shape.isTrigger = capsule.isTrigger;
shape.rigidbodyIndex = source.Rigidbody != null ? source.Rigidbody.Handle.index : -1;
shape.materialIndex = source.CollisionMaterial != null ? source.CollisionMaterial.handle.index : -1;
shape.forceZoneIndex = source.ForceZone != null ? source.ForceZone.Handle.index : -1;
shape.contactOffset = source.Thickness;
shape.center = capsule.offset;
Vector2 size = capsule.size;
shape.size = new Vector4((capsule.direction == CapsuleDirection2D.Horizontal ? size.y : size.x) * 0.5f,
Mathf.Max(size.x, size.y),
capsule.direction == CapsuleDirection2D.Horizontal ? 0 : 1, 0);
world.colliderShapes[index] = shape;
// update bounds:
var aabb = world.colliderAabbs[index];
aabb.FromBounds(capsule.bounds, shape.contactOffset,true);
world.colliderAabbs[index] = aabb;
// update transform:
var trfm = world.colliderTransforms[index];
trfm.FromTransform2D(capsule.transform, source.Rigidbody as ObiRigidbody2D);
world.colliderTransforms[index] = trfm;
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: fe1cd08d83cfe4785b8d5bb8e0bd3dd9
timeCreated: 1501961541
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,52 @@
using System;
using UnityEngine;
namespace Obi{
public class ObiCircleShapeTracker2D : ObiShapeTracker
{
public ObiCircleShapeTracker2D(ObiCollider2D source, CircleCollider2D collider)
{
this.source = source;
this.collider = collider;
}
public override void UpdateIfNeeded ()
{
CircleCollider2D sphere = collider as CircleCollider2D;
// retrieve collision world and index:
var world = ObiColliderWorld.GetInstance();
int index = source.Handle.index;
// update collider:
var shape = world.colliderShapes[index];
shape.is2D = true;
shape.type = ColliderShape.ShapeType.Sphere;
shape.filter = source.Filter;
shape.SetSign(source.Inverted);
shape.isTrigger = sphere.isTrigger;
shape.rigidbodyIndex = source.Rigidbody != null ? source.Rigidbody.Handle.index : -1;
shape.materialIndex = source.CollisionMaterial != null ? source.CollisionMaterial.handle.index : -1;
shape.forceZoneIndex = source.ForceZone != null ? source.ForceZone.Handle.index : -1;
shape.contactOffset = source.Thickness;
shape.center = sphere.offset;
shape.size = Vector3.one * sphere.radius;
world.colliderShapes[index] = shape;
// update bounds:
var aabb = world.colliderAabbs[index];
aabb.FromBounds(sphere.bounds, shape.contactOffset, true);
world.colliderAabbs[index] = aabb;
// update transform:
var trfm = world.colliderTransforms[index];
trfm.FromTransform2D(sphere.transform, source.Rigidbody as ObiRigidbody2D);
world.colliderTransforms[index] = trfm;
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 4290734bafa8c46d8862202365a9f83b
timeCreated: 1501960324
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,72 @@
using System;
using UnityEngine;
using System.Runtime.InteropServices;
namespace Obi{
public class ObiEdgeShapeTracker2D : ObiShapeTracker
{
ObiEdgeMeshHandle handle;
public ObiEdgeShapeTracker2D(ObiCollider2D source, EdgeCollider2D collider)
{
this.source = source;
this.collider = collider;
}
public void UpdateEdgeData()
{
ObiColliderWorld.GetInstance().DestroyEdgeMesh(handle);
}
public override void UpdateIfNeeded (){
EdgeCollider2D edgeCollider = collider as EdgeCollider2D;
// retrieve collision world and index:
var world = ObiColliderWorld.GetInstance();
int index = source.Handle.index;
// get or create the mesh:
if (handle == null || !handle.isValid)
{
handle = world.GetOrCreateEdgeMesh(edgeCollider);
handle.Reference();
}
// update collider:
var shape = world.colliderShapes[index];
shape.is2D = true;
shape.type = ColliderShape.ShapeType.EdgeMesh;
shape.filter = source.Filter;
shape.SetSign(source.Inverted);
shape.isTrigger = edgeCollider.isTrigger;
shape.rigidbodyIndex = source.Rigidbody != null ? source.Rigidbody.Handle.index : -1;
shape.materialIndex = source.CollisionMaterial != null ? source.CollisionMaterial.handle.index : -1;
shape.forceZoneIndex = source.ForceZone != null ? source.ForceZone.Handle.index : -1;
shape.center = edgeCollider.offset;
shape.contactOffset = source.Thickness + edgeCollider.edgeRadius;
shape.dataIndex = handle.index;
world.colliderShapes[index] = shape;
// update bounds:
var aabb = world.colliderAabbs[index];
aabb.FromBounds(edgeCollider.bounds, shape.contactOffset, true);
world.colliderAabbs[index] = aabb;
// update transform:
var trfm = world.colliderTransforms[index];
trfm.FromTransform2D(edgeCollider.transform, source.Rigidbody as ObiRigidbody2D);
world.colliderTransforms[index] = trfm;
}
public override void Destroy()
{
base.Destroy();
if (handle != null && handle.Dereference())
ObiColliderWorld.GetInstance().DestroyEdgeMesh(handle);
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 2d2b0912e5ba74985bb209d365e52f4b
timeCreated: 1502808634
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 3eba36295266249e08782d3327db66cd
folderAsset: yes
timeCreated: 1503483325
licenseType: Store
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,51 @@
using System;
using UnityEngine;
namespace Obi{
public class ObiBoxShapeTracker : ObiShapeTracker
{
public ObiBoxShapeTracker(ObiCollider source, BoxCollider collider)
{
this.source = source;
this.collider = collider;
}
public override void UpdateIfNeeded (){
BoxCollider box = collider as BoxCollider;
// retrieve collision world and index:
var world = ObiColliderWorld.GetInstance();
int index = source.Handle.index;
// update collider:
var shape = world.colliderShapes[index];
shape.type = ColliderShape.ShapeType.Box;
shape.filter = source.Filter;
shape.SetSign(source.Inverted);
shape.isTrigger = box.isTrigger;
shape.rigidbodyIndex = source.Rigidbody != null ? source.Rigidbody.Handle.index : -1;
shape.materialIndex = source.CollisionMaterial != null ? source.CollisionMaterial.handle.index : -1;
shape.forceZoneIndex = source.ForceZone != null ? source.ForceZone.Handle.index : -1;
shape.contactOffset = source.Thickness;
shape.center = box.center;
shape.size = box.size;
world.colliderShapes[index] = shape;
// update bounds:
var aabb = world.colliderAabbs[index];
aabb.FromBounds(box.bounds, shape.contactOffset);
world.colliderAabbs[index] = aabb;
// update transform:
var trfm = world.colliderTransforms[index];
trfm.FromTransform3D(box.transform, source.Rigidbody as ObiRigidbody);
world.colliderTransforms[index] = trfm;
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 7f9acb590fcdd47838d4e1929e463712
timeCreated: 1501960568
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,49 @@
using System;
using UnityEngine;
namespace Obi{
public class ObiCapsuleShapeTracker : ObiShapeTracker
{
public ObiCapsuleShapeTracker(ObiCollider source, CapsuleCollider collider){
this.collider = collider;
this.source = source;
}
public override void UpdateIfNeeded (){
CapsuleCollider capsule = collider as CapsuleCollider;
// retrieve collision world and index:
var world = ObiColliderWorld.GetInstance();
int index = source.Handle.index;
// update collider:
var shape = world.colliderShapes[index];
shape.type = ColliderShape.ShapeType.Capsule;
shape.filter = source.Filter;
shape.SetSign(source.Inverted);
shape.isTrigger = capsule.isTrigger;
shape.rigidbodyIndex = source.Rigidbody != null ? source.Rigidbody.Handle.index : -1;
shape.materialIndex = source.CollisionMaterial != null ? source.CollisionMaterial.handle.index : -1;
shape.forceZoneIndex = source.ForceZone != null ? source.ForceZone.Handle.index : -1;
shape.contactOffset = source.Thickness;
shape.center = capsule.center;
shape.size = new Vector4(capsule.radius, capsule.height, capsule.direction, 0);
world.colliderShapes[index] = shape;
// update bounds:
var aabb = world.colliderAabbs[index];
aabb.FromBounds(capsule.bounds, shape.contactOffset);
world.colliderAabbs[index] = aabb;
// update transform:
var trfm = world.colliderTransforms[index];
trfm.FromTransform3D(capsule.transform, source.Rigidbody as ObiRigidbody);
world.colliderTransforms[index] = trfm;
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: ab81f697ad33c47c0b487129c7ef1761
timeCreated: 1501961541
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,52 @@
using System;
using UnityEngine;
namespace Obi
{
public class ObiCharacterControllerShapeTracker : ObiShapeTracker
{
public ObiCharacterControllerShapeTracker(ObiCollider source, CharacterController collider)
{
this.collider = collider;
this.source = source;
}
public override void UpdateIfNeeded()
{
CharacterController character = collider as CharacterController;
// retrieve collision world and index:
var world = ObiColliderWorld.GetInstance();
int index = source.Handle.index;
// update collider:
var shape = world.colliderShapes[index];
shape.type = ColliderShape.ShapeType.Capsule;
shape.filter = source.Filter;
shape.SetSign(source.Inverted);
shape.isTrigger = character.isTrigger;
shape.rigidbodyIndex = source.Rigidbody != null ? source.Rigidbody.Handle.index : -1;
shape.materialIndex = source.CollisionMaterial != null ? source.CollisionMaterial.handle.index : -1;
shape.forceZoneIndex = source.ForceZone != null ? source.ForceZone.Handle.index : -1;
shape.contactOffset = source.Thickness;
shape.center = character.center;
shape.size = new Vector4(character.radius, character.height, 1, 0);
world.colliderShapes[index] = shape;
// update bounds:
var aabb = world.colliderAabbs[index];
aabb.FromBounds(character.bounds, shape.contactOffset);
world.colliderAabbs[index] = aabb;
// update transform:
var trfm = world.colliderTransforms[index];
trfm.FromTransform3D(character.transform, source.Rigidbody as ObiRigidbody);
world.colliderTransforms[index] = trfm;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 3c77ed89a210345ce9e9e549d11263db
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,88 @@
using System;
using System.Collections.Generic;
using UnityEngine;
using System.Runtime.InteropServices;
namespace Obi{
public class ObiDistanceFieldShapeTracker : ObiShapeTracker
{
public ObiDistanceField distanceField;
ObiDistanceFieldHandle handle;
public ObiDistanceFieldShapeTracker(ObiCollider source, Component collider, ObiDistanceField distanceField){
this.source = source;
this.collider = collider;
this.distanceField = distanceField;
}
/**
* Forces the tracker to update distance field data during the next call to UpdateIfNeeded().
*/
public void UpdateDistanceFieldData()
{
ObiColliderWorld.GetInstance().DestroyDistanceField(handle);
}
public override void UpdateIfNeeded ()
{
bool trigger = false;
if (collider is Collider) trigger = ((Collider)collider).isTrigger;
else if (collider is Collider2D) trigger = ((Collider2D)collider).isTrigger;
// retrieve collision world and index:
var world = ObiColliderWorld.GetInstance();
int index = source.Handle.index;
// decrease reference count of current handle if the df data it points to is different
// than the df used by the collider:
if (handle != null && handle.owner != distanceField)
{
if (handle.Dereference())
world.DestroyDistanceField(handle);
}
if (handle == null || !handle.isValid)
{
handle = world.GetOrCreateDistanceField(distanceField);
handle.Reference();
}
// update collider:
var shape = world.colliderShapes[index];
shape.type = ColliderShape.ShapeType.SignedDistanceField;
shape.filter = source.Filter;
shape.SetSign(source.Inverted);
shape.isTrigger = trigger;
shape.rigidbodyIndex = source.Rigidbody != null ? source.Rigidbody.Handle.index : -1;
shape.materialIndex = source.CollisionMaterial != null ? source.CollisionMaterial.handle.index : -1;
shape.forceZoneIndex = source.ForceZone != null ? source.ForceZone.Handle.index : -1;
shape.contactOffset = source.Thickness;
shape.dataIndex = handle.index;
world.colliderShapes[index] = shape;
// update bounds:
var aabb = world.colliderAabbs[index];
aabb.FromBounds(distanceField.FieldBounds.Transform(source.transform.localToWorldMatrix), shape.contactOffset);
world.colliderAabbs[index] = aabb;
// update transform:
var trfm = world.colliderTransforms[index];
trfm.FromTransform3D(source.transform, source.Rigidbody as ObiRigidbody);
world.colliderTransforms[index] = trfm;
}
public override void Destroy()
{
base.Destroy();
if (handle != null && handle.Dereference())
ObiColliderWorld.GetInstance().DestroyDistanceField(handle);
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: b9b443b752c21400ca6cfc151526f107
timeCreated: 1504879085
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,91 @@
using System;
using System.Collections.Generic;
using UnityEngine;
using System.Runtime.InteropServices;
namespace Obi{
public class ObiMeshShapeTracker : ObiShapeTracker
{
ObiTriangleMeshHandle handle;
public Mesh targetMesh
{
get {
var mc = collider as MeshCollider;
return mc?.sharedMesh;
}
}
public ObiMeshShapeTracker(ObiCollider source, MeshCollider collider){
this.source = source;
this.collider = collider;
}
/**
* Forces the tracker to update mesh data during the next call to UpdateIfNeeded().
*/
public void UpdateMeshData()
{
ObiColliderWorld.GetInstance().DestroyTriangleMesh(handle);
}
public override void UpdateIfNeeded ()
{
MeshCollider meshCollider = collider as MeshCollider;
// retrieve collision world and index:
var world = ObiColliderWorld.GetInstance();
int index = source.Handle.index;
// decrease reference count of current handle if the mesh data it points to is different
// than the mesh used by the collider:
if (handle != null && handle.owner != meshCollider.sharedMesh)
{
if (handle.Dereference())
world.DestroyTriangleMesh(handle);
}
// get or create the mesh:
if (handle == null || !handle.isValid)
{
handle = world.GetOrCreateTriangleMesh(meshCollider.sharedMesh);
handle.Reference();
}
// update collider:
var shape = world.colliderShapes[index];
shape.type = ColliderShape.ShapeType.TriangleMesh;
shape.filter = source.Filter;
shape.SetSign(source.Inverted);
shape.isTrigger = meshCollider.isTrigger;
shape.rigidbodyIndex = source.Rigidbody != null ? source.Rigidbody.Handle.index : -1;
shape.materialIndex = source.CollisionMaterial != null ? source.CollisionMaterial.handle.index : -1;
shape.forceZoneIndex = source.ForceZone != null ? source.ForceZone.Handle.index : -1;
shape.contactOffset = source.Thickness;
shape.dataIndex = handle.index;
world.colliderShapes[index] = shape;
// update bounds:
var aabb = world.colliderAabbs[index];
aabb.FromBounds(meshCollider.bounds, shape.contactOffset);
world.colliderAabbs[index] = aabb;
// update transform:
var trfm = world.colliderTransforms[index];
trfm.FromTransform3D(meshCollider.transform, source.Rigidbody as ObiRigidbody);
world.colliderTransforms[index] = trfm;
}
public override void Destroy()
{
base.Destroy();
if (handle != null && handle.Dereference())
ObiColliderWorld.GetInstance().DestroyTriangleMesh(handle);
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: c955001531e3444fd9615a5272954dea
timeCreated: 1502875710
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,20 @@
using System;
using UnityEngine;
namespace Obi{
public abstract class ObiShapeTracker
{
protected ObiColliderBase source;
protected Component collider;
public virtual void Destroy(){
}
public abstract void UpdateIfNeeded ();
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 5f455a735ac894ee7bddecd2b5a64ca8
timeCreated: 1501960324
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,50 @@
using System;
using UnityEngine;
namespace Obi{
public class ObiSphereShapeTracker : ObiShapeTracker
{
public ObiSphereShapeTracker(ObiCollider source, SphereCollider collider)
{
this.source = source;
this.collider = collider;
}
public override void UpdateIfNeeded()
{
SphereCollider sphere = collider as SphereCollider;
// retrieve collision world and index:
var world = ObiColliderWorld.GetInstance();
int index = source.Handle.index;
// update collider:
var shape = world.colliderShapes[index];
shape.type = ColliderShape.ShapeType.Sphere;
shape.filter = source.Filter;
shape.SetSign(source.Inverted);
shape.isTrigger = sphere.isTrigger;
shape.rigidbodyIndex = source.Rigidbody != null ? source.Rigidbody.Handle.index : -1;
shape.materialIndex = source.CollisionMaterial != null ? source.CollisionMaterial.handle.index : -1;
shape.forceZoneIndex = source.ForceZone != null ? source.ForceZone.Handle.index : -1;
shape.contactOffset = source.Thickness;
shape.center = sphere.center;
shape.size = Vector3.one * sphere.radius;
world.colliderShapes[index] = shape;
// update bounds:
var aabb = world.colliderAabbs[index];
aabb.FromBounds(sphere.bounds, shape.contactOffset);
world.colliderAabbs[index] = aabb;
// update transform:
var trfm = world.colliderTransforms[index];
trfm.FromTransform3D(sphere.transform, source.Rigidbody as ObiRigidbody);
world.colliderTransforms[index] = trfm;
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 221c651500acc4cbfa30ed329aebb822
timeCreated: 1501960324
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,75 @@
using System;
using UnityEngine;
using System.Runtime.InteropServices;
namespace Obi{
public class ObiTerrainShapeTracker : ObiShapeTracker
{
ObiHeightFieldHandle handle;
public ObiTerrainShapeTracker(ObiCollider source, TerrainCollider collider){
this.source = source;
this.collider = collider;
}
public void UpdateHeightData()
{
ObiColliderWorld.GetInstance().DestroyHeightField(handle);
}
public override void UpdateIfNeeded ()
{
TerrainCollider terrain = collider as TerrainCollider;
// retrieve collision world and index:
var world = ObiColliderWorld.GetInstance();
int index = source.Handle.index;
int resolution = terrain.terrainData.heightmapResolution;
// get or create the heightfield:
if (handle == null || !handle.isValid)
{
handle = world.GetOrCreateHeightField(terrain.terrainData);
handle.Reference();
}
// update collider:
var shape = world.colliderShapes[index];
shape.type = ColliderShape.ShapeType.Heightmap;
shape.filter = source.Filter;
shape.SetSign(source.Inverted);
shape.isTrigger = terrain.isTrigger;
shape.rigidbodyIndex = source.Rigidbody != null ? source.Rigidbody.Handle.index : -1;
shape.materialIndex = source.CollisionMaterial != null ? source.CollisionMaterial.handle.index : -1;
shape.forceZoneIndex = source.ForceZone != null ? source.ForceZone.Handle.index : -1;
shape.contactOffset = source.Thickness;
shape.dataIndex = handle.index;
shape.size = terrain.terrainData.size;
shape.center = new Vector4(resolution, resolution, resolution, resolution);
world.colliderShapes[index] = shape;
// update bounds:
var aabb = world.colliderAabbs[index];
aabb.FromBounds(terrain.bounds, shape.contactOffset);
world.colliderAabbs[index] = aabb;
// update transform:
var trfm = world.colliderTransforms[index];
trfm.FromTransform3D(terrain.transform, source.Rigidbody as ObiRigidbody);
world.colliderTransforms[index] = trfm;
}
public override void Destroy()
{
base.Destroy();
if (handle != null && handle.Dereference())
ObiColliderWorld.GetInstance().DestroyHeightField(handle);
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 601187ba897f54e20b787637df64e96b
timeCreated: 1502808634
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: