public void initialize(PlanetariaCollider observed, PlanetariaMonoBehaviour[] observers) { this.planetaria_collider = observed; this.planetaria_rigidbody = observed.GetComponent <PlanetariaRigidbody>(); this.planetaria_transformation = observed.GetComponent <PlanetariaTransform>(); foreach (PlanetariaMonoBehaviour observer in observers) { if (!this.observers.Contains(observer)) { this.observers.Add(observer); } } }
//barycentricCoordinate The barycentric coordinate of the triangle we hit. // RESEARCH: are there any equivalents to triangles I should be creating? //lightmapCoord The uv lightmap coordinate at the impact point. //textureCoord The uv texture coordinate at the collision location. //textureCoord2 The secondary uv texture coordinate at the impact point. //triangleIndex The index of the triangle that was hit. /// <summary> /// Constructor - creates the Planetaria equivalent of UnityEngine.RaycastHit /// </summary> /// <param name="raycast_arc">The path along which the raycast (inverse path for negative distances).</param> /// <param name="geometry_arc">The arc which intersects the raycast (i.e. the arc hit).</param> /// <param name="intersection_point">The intersection point of two circular arcs in 3D space.</param> /// <returns>The result of a point sweep / raycast in spherical 2D space.</returns> private PlanetariaRaycastHit(Arc raycast_arc, PlanetariaCollider planetaria_collider, Arc geometry_arc, Vector3 intersection_point, float raycast_distance) { arc = geometry_arc; collider = planetaria_collider; distance = raycast_arc.position_to_angle(intersection_point) * (raycast_arc.length() / raycast_arc.angle()); // TODO: verify distance += raycast_arc.length() / 2; if (raycast_distance < 0) { distance = raycast_arc.length() - distance; } positive_face_collision = true; // FIXME: HACK: LAZY: // also dynamic changes Transform internal_transform = collider.gameObject.internal_game_object.GetComponent <Transform>(); Quaternion arc_to_world = internal_transform.rotation; Quaternion world_to_arc = Quaternion.Inverse(arc_to_world); Vector3 local_intersection_point = world_to_arc * intersection_point; float angle = raycast_arc.position_to_angle(local_intersection_point); Vector3 local_normal = raycast_arc.normal(angle); normal = arc_to_world * local_normal; point = intersection_point; rigidbody = collider.GetComponent <PlanetariaRigidbody>(); transform = Miscellaneous.GetOrAddComponent <PlanetariaTransform>(collider); }