2 * Copyright (c) 2007-2010 SlimDX Group
4 * Permission is hereby granted, free of charge, to any person obtaining a copy
5 * of this software and associated documentation files (the "Software"), to deal
6 * in the Software without restriction, including without limitation the rights
7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 * copies of the Software, and to permit persons to whom the Software is
9 * furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24 using System.Globalization;
25 using System.Runtime.InteropServices;
31 /// Represents a vertex with a position and a color.
33 [StructLayout(LayoutKind.Sequential)]
34 public struct ColoredVertex : IEquatable<ColoredVertex> {
36 /// Gets or sets the position of the vertex.
38 public Vector3 Position {
44 /// Gets or sets the color of the vertex.
52 /// Initializes a new instance of the <see cref="ColoredVertex"/> struct.
54 /// <param name="position">The position.</param>
55 /// <param name="color">The color.</param>
56 public ColoredVertex(Vector3 position, int color)
63 /// Implements operator ==.
65 /// <param name="left">The left.</param>
66 /// <param name="right">The right.</param>
67 /// <returns>The result of the operator.</returns>
68 public static bool operator ==(ColoredVertex left, ColoredVertex right) {
69 return left.Equals(right);
73 /// Implements operator !=.
75 /// <param name="left">The left side of the operator.</param>
76 /// <param name="right">The right side of the operator.</param>
77 /// <returns>The result of the operator.</returns>
78 public static bool operator !=(ColoredVertex left, ColoredVertex right) {
79 return !(left == right);
83 /// Returns the hash code for this instance.
86 /// A 32-bit signed integer that is the hash code for this instance.
88 public override int GetHashCode() {
89 return Position.GetHashCode() + Color.GetHashCode();
93 /// Indicates whether this instance and a specified object are equal.
95 /// <param name="obj">Another object to compare to.</param>
97 /// true if <paramref name="obj"/> and this instance are the same type and represent the same value; otherwise, false.
99 public override bool Equals(object obj) {
103 if (GetType() != obj.GetType())
106 return Equals((ColoredVertex)obj);
110 /// Indicates whether the current object is equal to another object of the same type.
112 /// <param name="other">An object to compare with this object.</param>
114 /// true if the current object is equal to the <paramref name="other"/> parameter; otherwise, false.
116 public bool Equals(ColoredVertex other) {
117 return (Position == other.Position && Color == other.Color);