void AddChild(Entity parentEntity, Entity childEntity) { // LocalToWorld childLTW = EntityManager.GetComponentData< LocalToWorld >( childEntity ); // child's LocalToWorld is not updated yet!!! Matrix4x4 m = Matrix4x4.identity; m.SetTRS( EntityManager.GetComponentData <Translation>(childEntity).Value, Quaternion.identity, EntityManager.GetComponentData <Scale>(childEntity).Value *Vector3.one ); LocalToWorld childLTW = new LocalToWorld { Value = m }; LocalToWorld parentLTW = EntityManager.GetComponentData <LocalToWorld>(parentEntity); float4x4 w2p = math.inverse(parentLTW.Value); float4x4 l2p = math.mul(w2p, childLTW.Value); float3 tr = math.transform(l2p, float3.zero); PostUpdateCommands.AddComponent(childEntity, new LocalToParent()); PostUpdateCommands.AddComponent(childEntity, new Parent { Value = parentEntity }); PostUpdateCommands.SetComponent(childEntity, new Translation { Value = tr }); PostUpdateCommands.SetComponent(childEntity, new Scale { Value = 1 }); }
protected override void OnUpdate() { Entities.ForEach((Entity unitEntity, ref HasTarget hasTarget, ref Translation translation, ref LocalToWorld localToWorld) => { if (World.DefaultGameObjectInjectionWorld.EntityManager.Exists(hasTarget.TargetEntity)) { Translation targetTranslation = World.DefaultGameObjectInjectionWorld.EntityManager.GetComponentData <Translation>( hasTarget.TargetEntity); LocalToWorld targetLocalToWorld = World.DefaultGameObjectInjectionWorld.EntityManager.GetComponentData <LocalToWorld>( hasTarget.TargetEntity); float3 targetDirection = math.normalize(targetTranslation.Value - translation.Value); float moveSpeed = 10f; translation.Value += targetDirection * moveSpeed * Time.DeltaTime; // If are Unit if close to the target, destroy it if (math.distance(translation.Value, targetTranslation.Value) < .2f) { PostUpdateCommands.DestroyEntity(hasTarget.TargetEntity); PostUpdateCommands.RemoveComponent(unitEntity, typeof(HasTarget)); } } else { PostUpdateCommands.RemoveComponent(unitEntity, typeof(HasTarget)); } }); }
protected override void OnUpdate() { //Обновление мировых позиций для "верхних" сущностей Entities .WithNone <ParentComponent, PreviousParent>() .ForEach((Entity entity, ref LocalToWorld localToWorld, in TransformComponent transform) => //change ref Trans to in Trans { var scale = float4x4.Scale(transform.scale); localToWorld = new LocalToWorld { Value = math.mul(new float4x4(transform.rotation, transform.Position3), scale) }; UpdateChildTransform(entity, localToWorld); }).WithoutBurst().WithStructuralChanges().Run(); //Обновление мировых позиций для сущностей, которые потеряли родителей Entities .WithNone <ParentComponent>() .ForEach((Entity entity, ref LocalToWorld localToWorld, ref TransformComponent transform, in PreviousParent parent) => { var scale = math.length(localToWorld.Value.c0.xyz); transform = new TransformComponent { position = new float2(localToWorld.Value.c3.x, localToWorld.Value.c3.y), rotation = new quaternion(localToWorld.Value), scale = scale }; UpdateChildTransform(entity, localToWorld); }).WithoutBurst().WithStructuralChanges().Run(); }
public void Execute() { EntityManager entityManager = World.DefaultGameObjectInjectionWorld.EntityManager; EntityArchetype archetype = entityManager.CreateArchetype( typeof(RenderMesh), typeof(RenderBounds), typeof(WorldRenderBounds), typeof(ChunkWorldRenderBounds), typeof(LocalToWorld), typeof(MovementData)); foreach (var entity in Entities) { //get matrix and add new position LocalToWorld localToWorld = entityManager.GetComponentData <LocalToWorld>(entity); localToWorld.Value += float4x4.Translate(EntityPlacementPosition); //copy render mesh information RenderMesh renderMesh = entityManager.GetSharedComponentData <RenderMesh>(entity); //create entity and assign values Entity newEntity = entityManager.CreateEntity(archetype); entityManager.SetSharedComponentData(newEntity, renderMesh); entityManager.SetComponentData(newEntity, localToWorld); } Entities.Dispose(); }
protected override void OnStartRunning() { var entitySpawnData = GetSingleton <EntitySpawnData>(); var gridSize = entitySpawnData.SpawnGrid; _entitySpacing = entitySpawnData.EntitySpacing; for (int x = 0; x < gridSize.x; x++) { for (int y = 0; y < gridSize.y; y++) { var newEntity = EntityManager.Instantiate(entitySpawnData.EntityPrefab); var newPosition = new LocalToWorld { Value = CalculateTransform(x, y) }; EntityManager.SetComponentData(newEntity, newPosition); if ((x + y) % 2 == 0) { EntityManager.AddComponent <OscillatingTag>(newEntity); } } } }
public override void UpdateSystem() { Dependency = JobHandle.CombineDependencies(Dependency, m_raycastSystem.RaycastSystemDependency); if (m_inputManagementSystem.InputData.inputActions.spawn) { NativeArray <RaycastResult> raycastResult = m_raycastSystem.RaycastResult; NativeQueue <SpawnCommand> spawnQueueLocal = spawnQueue; NativeArray2D <MapNode> grid = m_gridManager.Grid; Dependency = Entities.WithReadOnly(grid).WithReadOnly(raycastResult).ForEach((ref RuntimePrefabData runtimePrefabData) => { if (raycastResult[0].raycastTargetType == RaycastTargetType.Ground) { Rotation rotation = GetComponent <Rotation>(runtimePrefabData.aiDrone); Translation translation = new Translation { Value = raycastResult[0].hitPosition + new float3(0, 1, 0) }; LocalToWorld localToWorld = new LocalToWorld { Value = new float4x4(rotation.Value, translation.Value) }; PathFinding pathFinding = new PathFinding { currentNode = PathFindingSystem.FindNearestNode(translation.Value, grid) }; SpawnCommands.SpawnHarvester(spawnQueueLocal, runtimePrefabData.aiDrone, translation, localToWorld, pathFinding); } }).Schedule(Dependency); spawnQueueDependencies = Dependency; } }
public static Entity CreateChildEntity(EntityManager em, Entity parentEntity, LocalToWorld lw, float3 posOffset, float3 rotOffset, string name = "Child") { var child = em.CreateEntity(); #if UNITY_EDITOR em.SetName(child, parentEntity.ToString() + ">" + name); #endif posOffset = (lw.Forward * posOffset.z) + (lw.Up * posOffset.y) + (lw.Right * posOffset.x); em.AddBuffer <LinkedEntityGroup>(parentEntity).Add(new LinkedEntityGroup { Value = child }); em.AddBuffer <Child>(parentEntity).Add(new Child { Value = child }); em.AddComponentData(child, new Translation { Value = posOffset }); em.AddComponentData(child, new Rotation { Value = math.mul(quaternion.LookRotation(lw.Forward, lw.Up), quaternion.EulerXYZ(rotOffset)) }); em.AddComponentData(child, new LocalToWorld { }); em.AddComponentData(child, new LocalToParent { }); em.AddComponentData(child, new Parent { Value = parentEntity }); return(child); }
public void Execute(Entity entity, int index, ref RangeWeapon weapon, [ReadOnly] ref AttackInputs attackInputs) { if (attackInputs.AttackHeld) { if (Time >= weapon.LastTimeShot + (1f / weapon.FiringRate)) { LocalToWorld localToWorld = LocalToWorldFromEntity[weapon.ShootPointEntity]; // store gun forward direction quaternion dir = quaternion.LookRotationSafe(localToWorld.Forward, localToWorld.Up); // convert angle to radians float spreadAngle = math.radians(30); // change angle over time spreadAngle = spreadAngle / 2 + math.abs(math.sin(Time * 2)) * spreadAngle / 2; // store angle slice per bullet quaternion diffraction = quaternion.EulerXYZ(0, spreadAngle / (math.ceil(weapon.BulletAmountPerShot) + 1), 0); // prepare offset 50% spreadAngle dir = math.mul(dir, quaternion.EulerXYZ(0, -spreadAngle / 2, 0)); for (int i = 0; i < math.ceil(weapon.BulletAmountPerShot); i++) { dir = math.mul(dir, diffraction); Entity spawnedProjectile = entityCommandBuffer.Instantiate(index, weapon.ProjectileEntity); entityCommandBuffer.SetComponent(index, spawnedProjectile, new Translation { Value = localToWorld.Position }); entityCommandBuffer.SetComponent(index, spawnedProjectile, new Rotation { Value = dir }); } weapon.LastTimeShot = Time; } } }
protected override JobHandle OnUpdate(JobHandle lastJobHandle) { var cartesianGridOnCube = GetSingleton <CartesianGridOnCube>(); var faceLocalToWorld = (float4x4 *)cartesianGridOnCube.Blob.Value.FaceLocalToWorld.GetUnsafePtr(); // Transform from grid-space Translation and gridFace to LocalToWorld for GridCube // - This is an example of overriding the transform system's default behavior. // - CubeFace is in the LocalToWorld WriteGroup, so when it this component is present, it is required to be // part of the query in order to write to LocalToWorld. Since the transform system doesn't know anything // about CubeFace, it will never be present in those default transformations. So it can be handled custom // here. lastJobHandle = Entities .WithName("CartesianGridOnCubeTransform") .WithNativeDisableUnsafePtrRestriction(faceLocalToWorld) .ForEach((ref LocalToWorld localToWorld, in Translation translation, in CartesianGridOnCubeFace cubeFace) => { var cubeFaceIndex = cubeFace.Value; var resultLocalToWorld = faceLocalToWorld[cubeFaceIndex]; resultLocalToWorld.c3 = math.mul(resultLocalToWorld, new float4(translation.Value, 1.0f)); localToWorld = new LocalToWorld { Value = resultLocalToWorld }; }).Schedule(lastJobHandle);
private void initialize(Entity brokenEntity) { if (brokenEntity != Entity.Null) { brokenEntities.Add(brokenEntity); } targetQuery = em.CreateEntityQuery(new ComponentType[] { typeof(Cannon) }); NativeArray <Entity> entities = targetQuery.ToEntityArray(Allocator.TempJob); for (int count = 0; count < entities.Length; count++) { if (brokenEntities.Contains(entities[count])) { continue; } trackTarget = entities[count]; trackTargetIndex = count; Translation targetTrans = em.GetComponentData <Translation>(trackTarget); Rotation targetRot = em.GetComponentData <Rotation>(trackTarget); LocalToWorld targetLTW = em.GetComponentData <LocalToWorld>(trackTarget); if (float.IsNaN(targetTrans.Value.x)) { break; } Vector3 startPosition = targetTrans.Value - targetLTW.Forward * FOLLOWDISTANCEZ; transform.position = startPosition; transform.LookAt(targetTrans.Value); initialized = true; //Debug.Log("Track target - " + trackTarget + " at " + targetTrans.Value); } //Debug.Log("FollowCamera - " + trackTarget); entities.Dispose(); }
public void Execute(ArchetypeChunk chunk, int chunkIndex, int firstEntityIndex) { NativeArray <Translation> chunkTranslations = chunk.GetNativeArray(translationType); NativeArray <Velocity> chunkVelocities = chunk.GetNativeArray(velocityType); NativeArray <Rotation> chunkRotations = chunk.GetNativeArray(rotationType); NativeArray <LocalToWorld> localToWorlds = chunk.GetNativeArray(localToWorldType); for (int i = 0; i < chunk.Count; i++) { Velocity velocity = chunkVelocities[i]; float speedSq = math.lengthsq(velocity.Value); if (speedSq > 0.01f) { Translation translation = chunkTranslations[i]; LocalToWorld localToWorld = localToWorlds[i]; float3 newPos = translation.Value + velocity.Value * deltaTime; chunkTranslations[i] = new Translation { Value = newPos }; quaternion newRotation = quaternion.LookRotation(velocity.Value, localToWorld.Up); chunkRotations[i] = new Rotation { Value = newRotation }; } } }
protected unsafe override void OnUpdate() { var current = new int2(Screen.width, Screen.height); if (res->Equals(current)) { return; } * res = current; int2 *local = res; var cmdBuffer = cmdBufferSystem.CreateCommandBuffer(); Dependency = Entities.ForEach((ref LocalToWorld c2, in ReferenceResolution c0, in WidthHeightRatio c1) => { var logWidth = math.log2(local->x / c0.Value.x); var logHeight = math.log2(local->y / c0.Value.y); var avg = math.lerp(logWidth, logHeight, c1.Value); var scale = math.pow(2, avg); var center = new float3(local->xy / 2, 0); c2 = new LocalToWorld { Value = float4x4.TRS(center, c2.Rotation, new float3(scale)) }; }).WithNativeDisableUnsafePtrRestriction(local).Schedule(Dependency);
protected override void OnUpdate() { float deltaTime = this.Time.DeltaTime; Entities .ForEach((ref Rotation orientation, in LocalToWorld transform, in Target target) => { // Check to make sure the target Entity still exists and has // the needed component if (!HasComponent <LocalToWorld>(target.entity)) { return; } // Look up the entity data LocalToWorld targetTransform = GetComponent <LocalToWorld>(target.entity); float3 targetPosition = targetTransform.Position; // Calculate the rotation float3 displacement = targetPosition - transform.Position; float3 upReference = new float3(0, 1, 0); quaternion lookRotation = quaternion.LookRotationSafe(displacement, upReference); orientation.Value = math.slerp(orientation.Value, lookRotation, deltaTime); })
public TriangleGlobals(LocalToWorld localToWorld, TriangleData triangleData) { G1 = math.transform(localToWorld.Value, triangleData.P1); G2 = math.transform(localToWorld.Value, triangleData.P2); G3 = math.transform(localToWorld.Value, triangleData.P3); Center = (G1 + G2 + G3) / 3f; }
public static void CreatePanel(EntityManager dstManager, Entity prefab, LocalToWorld localToWorld) { var panelEntity = dstManager.Instantiate(prefab); dstManager.RemoveComponent <Translation>(panelEntity); dstManager.RemoveComponent <Rotation>(panelEntity); dstManager.SetComponentData(panelEntity, localToWorld); }
private void Update() { if (entity != null) { entityTransform = entityManager.GetComponentData <LocalToWorld>(entity); transform.position = entityTransform.Position; } }
public void Convert(Entity entity, EntityManager dstManager, GameObjectConversionSystem conversionSystem) { var rigComponent = GetComponent <RigComponent>(); if (rigComponent != null) { var buffer = dstManager.AddBuffer <PhysicsColliderFollowEntityData>(entity); GetData(rigComponent, out Transform[] children, out var shapes); // children = new Transform[0]; if (children.Length > 1) { int numberOfValidShapes = GetNumberOfValidShapes(shapes); NativeList <CompoundCollider.ColliderBlobInstance> blobs = new NativeList <CompoundCollider.ColliderBlobInstance>(Allocator.TempJob); for (int i = 0; i < children.Length; i++) { if (shapes[i] != null && shapes[i].enabled) { var shapeExt = children[i].gameObject.GetComponent <PhysicsMaterialsExtensionComponent>(); BlobAssetReference <Unity.Physics.Collider> collider = GenerateCollider(shapes[i], shapeExt, out float3 offsetPosition, out quaternion offsetRotation); blobs.Add(new CompoundCollider.ColliderBlobInstance { CompoundFromChild = new RigidTransform(children[i].rotation, children[i].position - this.transform.position), Collider = collider }); var ltw = new LocalToWorld { Value = new float4x4(children[i].rotation, children[i].position - this.transform.position) }; buffer.Add(new PhysicsColliderFollowEntityData { AnimationDataIndex = i, CompoundColliderChildIndex = blobs.Length - 1, RootTransform = new RigidTransform(InitialRootRotation, InitialRootPosition), sourceEntity = conversionSystem.GetPrimaryEntity(shapes[i].gameObject), CompoundColliderDataIsSet = false, Old = ltw, Offset = ltw }); Debug.Log("Setting \"" + children[i].name + "\" to " + (blobs.Length - 1) + " animation index =" + i + ", valid shapes = " + numberOfValidShapes + ", belongs to " + shapes[i].BelongsTo.Value + ", collides with = " + shapes[i].CollidesWith.Value); // shapes[i].enabled = false; } } if (blobs.Length > 0) { dstManager.AddComponentData(entity, new PhysicsCollider { Value = CompoundCollider.Create(blobs) }); } blobs.Dispose(); } else if (children.Length == 1) { dstManager.AddComponentData(entity, new PhysicsCollider { Value = GenerateCollider(shapes[0], null, out var a, out var b) });
public LodRequirement(MeshLODGroupComponent lodGroup, LocalToWorld localToWorld, int lodMask) { var referencePoint = math.transform(localToWorld.Value, lodGroup.LocalReferencePoint); var minDist = float.MaxValue; var maxDist = 0.0F; if ((lodMask & 0x01) == 0x01) { minDist = 0.0f; maxDist = math.max(maxDist, lodGroup.LODDistances0.x); } if ((lodMask & 0x02) == 0x02) { minDist = math.min(minDist, lodGroup.LODDistances0.x); maxDist = math.max(maxDist, lodGroup.LODDistances0.y); } if ((lodMask & 0x04) == 0x04) { minDist = math.min(minDist, lodGroup.LODDistances0.y); maxDist = math.max(maxDist, lodGroup.LODDistances0.z); } if ((lodMask & 0x08) == 0x08) { minDist = math.min(minDist, lodGroup.LODDistances0.z); maxDist = math.max(maxDist, lodGroup.LODDistances0.w); } if ((lodMask & 0x10) == 0x10) { minDist = math.min(minDist, lodGroup.LODDistances0.w); maxDist = math.max(maxDist, lodGroup.LODDistances1.x); } if ((lodMask & 0x20) == 0x20) { minDist = math.min(minDist, lodGroup.LODDistances1.x); maxDist = math.max(maxDist, lodGroup.LODDistances1.y); } if ((lodMask & 0x40) == 0x40) { minDist = math.min(minDist, lodGroup.LODDistances1.y); maxDist = math.max(maxDist, lodGroup.LODDistances1.z); } if ((lodMask & 0x80) == 0x80) { minDist = math.min(minDist, lodGroup.LODDistances1.z); maxDist = math.max(maxDist, lodGroup.LODDistances1.w); } WorldReferencePosition = referencePoint; MinDist = minDist; MaxDist = maxDist; }
public static float GetAngle(float3 x, LocalToWorld y) { var targetVector = x - y.Position; var v = (y.Forward.x * targetVector.x + y.Forward.z * targetVector.z) / math.sqrt((y.Forward.x * y.Forward.x + y.Forward.z * y.Forward.z) * (targetVector.x * targetVector.x + targetVector.z * targetVector.z)); return(math.acos(v) * 180 / math.PI); }
private bool InViewCone(ref LocalToWorld localToWorld, float3 detectedPos, ref FieldOfView setting) { var dir = detectedPos - localToWorld.Position; var angle = Vector3.Angle(localToWorld.Forward, dir); var distance = math.lengthsq(dir); var inAngle = angle < setting.Angle * 0.5; var inDistance = distance < math.lengthsq(setting.Radius); return(inAngle && inDistance); }
public void Execute(Entity entity, int index, [ReadOnly] ref MirrorLocalToWorld mirror) { if (LocalToWorldData.Exists(mirror.Target)) { LocalToWorldData[entity] = new LocalToWorld { Value = LocalToWorldData[mirror.Target].Value } } ; } }
public static void CreateWallW(EntityManager dstManager, Entity prefab, float4x4 parentLocalToWorld, float tx, float tz) { var pos = new float3(tx, 1.0f, tz + 0.5f); var childLocalToParent = math.mul(float4x4.Translate(pos), float4x4.Scale(0.1f, 1.1f, 1.1f)); var localToWorld = new LocalToWorld { Value = math.mul(parentLocalToWorld, childLocalToParent) }; CreatePanel(dstManager, prefab, localToWorld); }
public static void CreateWallS(EntityManager dstManager, GameObjectConversionSystem conversionSystem, GameObject gameObject, GameObject prefab, float4x4 parentLocalToWorld, float tx, float tz) { var pos = new float3(tx + 0.5f, 1.0f, tz); var childLocalToParent = math.mul(float4x4.Translate(pos), float4x4.Scale(1.1f, 1.1f, 0.1f)); var localToWorld = new LocalToWorld { Value = math.mul(parentLocalToWorld, childLocalToParent) }; CreatePanel(dstManager, conversionSystem, gameObject, prefab, localToWorld); }
public Entity CrearRecurso(int idRecurso, float3 posicion) { if (contenedorRecursos.ContainsKey(idRecurso)) { AdministradorMateriales adminMaterial = AdministradorMateriales.Instanciar(); RecursosPlantilla recursoPlantilla = contenedorRecursos[idRecurso]; LocalToWorld localToWorld = new LocalToWorld(); localToWorld.Value = float4x4.TRS(posicion, Quaternion.Euler(0, recursoPlantilla.angulo, 0), new float3(1, 1, 1)); Translation translation = new Translation { Value = posicion }; RenderMesh renderMesh = new RenderMesh { mesh = recursoPlantilla.mallaMaestra, material = adminMaterial.ObtenerMaterial(recursoPlantilla.idMaterial).material, layer = 1 }; RenderBounds redn = new RenderBounds(); //redn.Value = recursoPlantilla.mallaMaestra.bounds.ToAABB().Extents; /* redn.Value = new AABB * { * Center = posicion * ,Extents = recursoPlantilla.mallaMaestra.bounds.ToAABB().Extents * * };*/ Recurso recurso = new Recurso { idRecurso = recursoPlantilla.idRecurso, cantidadRecurso = recursoPlantilla.cantidadRecurso }; EntityManager entityManager = World.DefaultGameObjectInjectionWorld.EntityManager; EntityArchetype archetype = entityManager.CreateArchetype( typeof(RenderMesh), typeof(RenderBounds), typeof(LocalToWorld), typeof(Recurso) ); Entity myEntity = entityManager.CreateEntity(archetype); entityManager.AddComponentData(myEntity, localToWorld); // entityManager.AddComponentData(myEntity, translation); // entityManager.AddComponentData(myEntity, redn); entityManager.AddSharedComponentData(myEntity, renderMesh); entityManager.AddComponentData(myEntity, recurso); return(myEntity); } return(default);
public void Execute(ArchetypeChunk batchInChunk, int batchIndex) { var boidChunk = batchInChunk.GetNativeArray(boidTypeHandle); var translationsChunk = batchInChunk.GetNativeArray(translationTypeHandle); var ltwChunk = batchInChunk.GetNativeArray(ltwTypeHandle); var obstacleAvoidanceChunk = batchInChunk.GetNativeArray(obstacleAvoidanceTypeHandle); var rotationChunk = batchInChunk.GetNativeArray(rotationTypeHandle); for (int i = 0; i < batchInChunk.Count; i++) { float3 force = Vector3.zero; Translation p = translationsChunk[i]; ObstacleAvoidance oa = obstacleAvoidanceChunk[i]; LocalToWorld ltw = ltwChunk[i]; Boid b = boidChunk[i]; Rotation r = rotationChunk[i]; oa.normal = Vector3.zero; oa.point = Vector3.zero; float3 forward = math.mul(r.Value, Vector3.forward); forward = math.normalize(forward); var input = new RaycastInput() { Start = p.Value, End = p.Value + (forward * oa.forwardFeelerDepth), //Filter = CollisionFilter.Default Filter = new CollisionFilter { BelongsTo = ~0u, CollidesWith = ~0u, GroupIndex = 0 } }; oa.start = input.Start; oa.end = input.End; Unity.Physics.RaycastHit hit; if (collisionWorld.CastRay(input, out hit)) { Debug.Log("Collides"); float dist = math.distance(hit.Position, p.Value); force += hit.SurfaceNormal * (oa.forwardFeelerDepth / dist); oa.normal = hit.SurfaceNormal; oa.point = hit.Position; } oa.force = force; obstacleAvoidanceChunk[i] = oa; } }
public void Execute(int i) { var entity = Entities[i]; var random = new Random(((uint)(entity.Index + i + 1) * 0x9F6ABC1)); var dir = math.normalizesafe(random.NextFloat3() - new float3(0.5f, 0.5f, 0.5f)); var pos = Center + (dir * Radius); var localToWorld = new LocalToWorld { Value = float4x4.TRS(pos, quaternion.LookRotationSafe(dir, math.up()), new float3(1.0f, 1.0f, 1.0f)) }; LocalToWorldFromEntity[entity] = localToWorld; }
public LodRequirement(MeshLODGroupComponent lodGroup, LocalToWorld localToWorld, int lodMask) { var referencePoint = math.transform(localToWorld.Value, lodGroup.LocalReferencePoint); float minDist = 0.0f; float maxDist = 0.0f; if ((lodMask & 0x01) == 0x01) { minDist = 0.0f; maxDist = lodGroup.LODDistances0.x; } else if ((lodMask & 0x02) == 0x02) { minDist = lodGroup.LODDistances0.x; maxDist = lodGroup.LODDistances0.y; } else if ((lodMask & 0x04) == 0x04) { minDist = lodGroup.LODDistances0.y; maxDist = lodGroup.LODDistances0.z; } else if ((lodMask & 0x08) == 0x08) { minDist = lodGroup.LODDistances0.z; maxDist = lodGroup.LODDistances0.w; } else if ((lodMask & 0x10) == 0x10) { minDist = lodGroup.LODDistances0.w; maxDist = lodGroup.LODDistances1.x; } else if ((lodMask & 0x20) == 0x20) { minDist = lodGroup.LODDistances1.x; maxDist = lodGroup.LODDistances1.y; } else if ((lodMask & 0x40) == 0x40) { minDist = lodGroup.LODDistances1.y; maxDist = lodGroup.LODDistances1.z; } else if ((lodMask & 0x80) == 0x80) { minDist = lodGroup.LODDistances1.z; maxDist = lodGroup.LODDistances1.w; } WorldReferencePosition = referencePoint; MinDist = minDist; MaxDist = maxDist; }
public void Execute(int i) { var pos = position_list_[i].Value; var rot = rotation_list_[i].Value; var start_time = start_time_list_[i].value_; var mat = new float4x4(rot, pos); var c0 = mat.c0; c0.w = start_time; mat.c0 = c0; local_to_world_list_[i] = new LocalToWorld { Value = mat, }; }
protected virtual void GenerateLayerData() { var tr = TargetTransform; var localScale = tr.localScale; localScale.z = 1f; var layer = Matrix4x4.TRS(tr.position, tr.rotation, Vector3.one); var local = Matrix4x4.Scale(localScale); LayerToWorld.Reset(layer); LocalToLayer.Reset(local); LocalToWorld.Reset(layer, local); }
public void HashLocalToWorld_HashUtilityResult_EqualsRawImplementation() { using (var world = new World("HashLocalToWorld_Test")) { var ltw = new LocalToWorld { Value = float4x4.identity }; var entity = world.EntityManager.CreateEntity(); world.EntityManager.AddComponent <LocalToWorld>(entity); world.EntityManager.SetComponentData(entity, ltw); Assert.AreEqual(LocalToWorldHash.HashTransforms(world, SeedForTesting), MimicChunkedLocalToWorldHash(ltw, SeedForTesting)); } }