4 using System.Collections.Generic;
5 using System.Collections.Specialized;
6 using SiliconStudio.Paradox.EntityModel;
7 using SiliconStudio.Paradox.Games;
8 using SiliconStudio.Core;
9 using SiliconStudio.Core.Collections;
10 using SiliconStudio.Core.Mathematics;
11 using SiliconStudio.Paradox.Threading;
13 namespace SiliconStudio.
Paradox.Engine
23 private readonly TrackingHashSet<TransformationComponent> transformationRoots =
new TrackingHashSet<TransformationComponent>();
29 private readonly FastCollection<TransformationComponent> notSpecialRootComponents =
new FastCollection<TransformationComponent>();
35 : base(new
PropertyKey[] { TransformationComponent.Key })
46 protected internal override void OnSystemAdd()
52 foreach (var entity
in rootEntities)
54 transformationRoots.Add(entity.Transformation);
59 protected internal override void OnSystemRemove()
61 transformationRoots.Clear();
64 internal static void UpdateTransformations(FastCollection<TransformationComponent> transformationComponents,
bool skipSpecialRoots)
67 if (transformationComponents.Count >= 1024)
70 transformationComponents,
73 (i, transformation) =>
75 if (skipSpecialRoots && transformation.isSpecialRoot)
78 UpdateTransformation(transformation);
81 if (transformation.Children.Count > 0)
82 UpdateTransformations(transformation.Children,
true);
88 foreach (var transformation
in transformationComponents)
90 if (skipSpecialRoots && transformation.isSpecialRoot)
93 UpdateTransformation(transformation);
96 if (transformation.Children.Count > 0)
97 UpdateTransformations(transformation.Children,
true);
102 private static void UpdateTransformation(TransformationComponent transformation)
105 transformation.UpdateLocalMatrix();
106 transformation.UpdateWorldMatrixNonRecursive();
115 notSpecialRootComponents.Clear();
116 foreach (var t
in transformationRoots)
118 notSpecialRootComponents.Add(t);
121 UpdateTransformations(notSpecialRootComponents,
false);
138 var cosX = (float)Math.Cos(rotation.X);
139 var sinX = (float)Math.Sin(rotation.X);
140 var cosY = (float)Math.Cos(rotation.Y);
141 var sinY = (float)Math.Sin(rotation.Y);
142 var cosZ = (float)Math.Cos(rotation.Z);
143 var sinZ = (float)Math.Sin(rotation.Z);
146 var sinZY = sinZ * sinY;
147 var cosXZ = cosZ * cosX;
148 var cosZsinY = cosZ * sinX;
151 result.M11 = cosZ * cosY;
152 result.M21 = cosZsinY * sinY - cosX * sinZ;
153 result.M31 = sinZ * sinX + cosXZ * sinY;
154 result.M12 = cosY * sinZ;
155 result.M22 = cosXZ + sinZY * sinX;
156 result.M32 = cosX * sinZY - cosZsinY;
158 result.M23 = cosY * sinX;
159 result.M33 = cosY * cosX;
181 case NotifyCollectionChangedAction.Add:
182 transformationRoots.Add(((
Entity)e.
Item).Transformation);
184 case NotifyCollectionChangedAction.Remove:
185 transformationRoots.Remove(((
Entity)e.
Item).Transformation);
Game entity. It usually aggregates multiple EntityComponent
Represents a three dimensional mathematical vector.
Entity processor, triggered on various EntitySystem events such as Entity and Component additions and...
This processor will take care of adding/removing children of every Entity added/removed in the Entity...
Current timing used for variable-step (real time) or fixed-step (game time) games.
object Item
Gets the added or removed item (if dictionary, value only).
NotifyCollectionChangedAction Action
Gets the type of action performed. Allowed values are NotifyCollectionChangedAction.Add and NotifyCollectionChangedAction.Remove.
A class that represents a tag propety.
Represents a 4x4 mathematical matrix.