Permalink
Browse files

Merge branch 'develop3d' of https://github.com/mono/MonoGame into dev…

…elop3d
  • Loading branch information...
2 parents 3e9dd59 + 48759f7 commit 19f1a9d30b80175bb6933d03b4a592aab1d9b53e Alexandre Zollinger Chohfi committed Feb 14, 2013
@@ -27,6 +27,7 @@ public override CompiledEffectContent Process(EffectContent input, ContentProces
var options = new Options();
options.SourceFile = input.Identity.SourceFilename;
options.DX11Profile = platform == MonoGamePlatform.Windows8 ? true : false;
+ options.Debug = DebugMode == EffectProcessorDebugMode.Debug;
options.OutputFile = context.OutputFilename;
// Parse the MGFX file expanding includes, macros, and returning the techniques.
@@ -37,16 +37,16 @@ Olivier Dufour (Duff)
namespace Microsoft.Xna.Framework
{
- #if WINRT
+#if WINRT
[DataContract]
- #else
+#else
[Serializable]
- #endif
+#endif
public struct BoundingBox : IEquatable<BoundingBox>
{
#region Public Fields
-
+
#if WINRT
[DataMember]
#endif
@@ -143,28 +143,81 @@ public ContainmentType Contains(BoundingFrustum frustum)
public ContainmentType Contains(BoundingSphere sphere)
{
- if (sphere.Center.X - Min.X > sphere.Radius
- && sphere.Center.Y - Min.Y > sphere.Radius
- && sphere.Center.Z - Min.Z > sphere.Radius
- && Max.X - sphere.Center.X > sphere.Radius
- && Max.Y - sphere.Center.Y > sphere.Radius
- && Max.Z - sphere.Center.Z > sphere.Radius)
+ if (sphere.Center.X - Min.X >= sphere.Radius
+ && sphere.Center.Y - Min.Y >= sphere.Radius
+ && sphere.Center.Z - Min.Z >= sphere.Radius
+ && Max.X - sphere.Center.X >= sphere.Radius
+ && Max.Y - sphere.Center.Y >= sphere.Radius
+ && Max.Z - sphere.Center.Z >= sphere.Radius)
return ContainmentType.Contains;
double dmin = 0;
- if (sphere.Center.X - Min.X <= sphere.Radius)
- dmin += (sphere.Center.X - Min.X) * (sphere.Center.X - Min.X);
- else if (Max.X - sphere.Center.X <= sphere.Radius)
- dmin += (sphere.Center.X - Max.X) * (sphere.Center.X - Max.X);
- if (sphere.Center.Y - Min.Y <= sphere.Radius)
- dmin += (sphere.Center.Y - Min.Y) * (sphere.Center.Y - Min.Y);
- else if (Max.Y - sphere.Center.Y <= sphere.Radius)
- dmin += (sphere.Center.Y - Max.Y) * (sphere.Center.Y - Max.Y);
- if (sphere.Center.Z - Min.Z <= sphere.Radius)
- dmin += (sphere.Center.Z - Min.Z) * (sphere.Center.Z - Min.Z);
- else if (Max.Z - sphere.Center.Z <= sphere.Radius)
- dmin += (sphere.Center.Z - Max.Z) * (sphere.Center.Z - Max.Z);
+ double e = sphere.Center.X - Min.X;
+ if (e < 0)
+ {
+ if (e < -sphere.Radius)
+ {
+ return ContainmentType.Disjoint;
+ }
+ dmin += e * e;
+ }
+ else
+ {
+ e = sphere.Center.X - Max.X;
+ if (e > 0)
+ {
+ if (e > sphere.Radius)
+ {
+ return ContainmentType.Disjoint;
+ }
+ dmin += e * e;
+ }
+ }
+
+ e = sphere.Center.Y - Min.Y;
+ if (e < 0)
+ {
+ if (e < -sphere.Radius)
+ {
+ return ContainmentType.Disjoint;
+ }
+ dmin += e * e;
+ }
+ else
+ {
+ e = sphere.Center.Y - Max.Y;
+ if (e > 0)
+ {
+ if (e > sphere.Radius)
+ {
+ return ContainmentType.Disjoint;
+ }
+ dmin += e * e;
+ }
+ }
+
+ e = sphere.Center.Z - Min.Z;
+ if (e < 0)
+ {
+ if (e < -sphere.Radius)
+ {
+ return ContainmentType.Disjoint;
+ }
+ dmin += e * e;
+ }
+ else
+ {
+ e = sphere.Center.Z - Max.Z;
+ if (e > 0)
+ {
+ if (e > sphere.Radius)
+ {
+ return ContainmentType.Disjoint;
+ }
+ dmin += e * e;
+ }
+ }
if (dmin <= sphere.Radius * sphere.Radius)
return ContainmentType.Intersects;
@@ -445,7 +498,7 @@ public void Intersects(ref Plane plane, out PlaneIntersectionType result)
result = PlaneIntersectionType.Back;
return;
}
-
+
result = PlaneIntersectionType.Intersecting;
}
@@ -477,4 +530,3 @@ public override string ToString()
#endregion Public Methods
}
}
-
@@ -431,10 +431,14 @@ private static EffectPassCollection ReadPasses(BinaryReader reader, Effect effec
private static EffectParameterCollection ReadParameters(BinaryReader reader)
{
var collection = new EffectParameterCollection();
- var count = (int)reader.ReadByte(); if (count == 0) return collection;
+ var count = (int)reader.ReadByte();
+ if (count == 0)
+ return collection;
+
for (var i = 0; i < count; i++)
{
- var class_ = (EffectParameterClass)reader.ReadByte(); var type = (EffectParameterType)reader.ReadByte();
+ var class_ = (EffectParameterClass)reader.ReadByte();
+ var type = (EffectParameterType)reader.ReadByte();
var name = reader.ReadString();
var semantic = reader.ReadString();
var annotations = ReadAnnotations(reader);
@@ -448,14 +452,36 @@ private static EffectParameterCollection ReadParameters(BinaryReader reader)
if (elements.Count == 0 && structMembers.Count == 0)
{
switch (type)
- { case EffectParameterType.Bool: case EffectParameterType.Int32: { var buffer = new int[rowCount * columnCount]; for (var j = 0; j < buffer.Length; j++) buffer[j] = reader.ReadInt32(); data = buffer; break; }
+ {
+ case EffectParameterType.Bool:
+ case EffectParameterType.Int32:
+#if DIRECTX
+ // Under DirectX we properly store integers and booleans
+ // in an integer type.
+ //
+ // MojoShader on the otherhand stores everything in float
+ // types which is why this code is disabled under OpenGL.
+ {
+ var buffer = new int[rowCount * columnCount];
+ for (var j = 0; j < buffer.Length; j++)
+ buffer[j] = reader.ReadInt32();
+ data = buffer;
+ break;
+ }
+#endif
+
case EffectParameterType.Single:
{
var buffer = new float[rowCount * columnCount];
- for (var j = 0; j < buffer.Length; j++) buffer[j] = reader.ReadSingle(); data = buffer; break; }
+ for (var j = 0; j < buffer.Length; j++)
+ buffer[j] = reader.ReadSingle();
+ data = buffer;
+ break;
+ }
case EffectParameterType.String:
throw new NotImplementedException();
- }; }
+ }
+ }
var param = new EffectParameter(
class_, type, name, rowCount, columnCount, semantic,
annotations, elements, structMembers, data);
Oops, something went wrong.

0 comments on commit 19f1a9d

Please sign in to comment.