mirror of
https://github.com/celisej567/LibBSP.git
synced 2026-01-02 21:48:34 +03:00
Add constructor to BrushSide to copy another BrushSide using any given format.
This commit is contained in:
@@ -160,7 +160,7 @@ namespace LibBSP {
|
||||
return BitConverter.ToSingle(Data, 0);
|
||||
}
|
||||
default: {
|
||||
return float.NaN;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -484,7 +484,46 @@ namespace LibBSP {
|
||||
Data = data;
|
||||
Parent = parent;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="BrushSide"/> by copying the fields in <paramref name="source"/>, using
|
||||
/// <paramref name="parent"/> to get <see cref="LibBSP.MapType"/> and <see cref="LumpInfo.version"/>
|
||||
/// to use when creating the new <see cref="BrushSide"/>.
|
||||
/// If the <paramref name="parent"/>'s <see cref="BSP"/>'s <see cref="LibBSP.MapType"/> is different from
|
||||
/// the one from <paramref name="source"/>, it does not matter, because fields are copied by name.
|
||||
/// </summary>
|
||||
/// <param name="source">The <see cref="BrushSide"/> to copy.</param>
|
||||
/// <param name="parent">
|
||||
/// The <see cref="ILump"/> to use as the <see cref="Parent"/> of the new <see cref="BrushSide"/>.
|
||||
/// Use <c>null</c> to use the <paramref name="source"/>'s <see cref="Parent"/> instead.
|
||||
/// </param>
|
||||
public BrushSide(BrushSide source, ILump parent) {
|
||||
Parent = parent;
|
||||
|
||||
if (parent != null && parent.Bsp != null) {
|
||||
if (source.Parent != null && source.Parent.Bsp != null && source.Parent.Bsp.version == parent.Bsp.version && source.LumpVersion == parent.LumpInfo.version) {
|
||||
Data = new byte[source.Data.Length];
|
||||
Array.Copy(source.Data, Data, source.Data.Length);
|
||||
return;
|
||||
} else {
|
||||
Data = new byte[GetStructLength(parent.Bsp.version, parent.LumpInfo.version)];
|
||||
}
|
||||
} else {
|
||||
if (source.Parent != null && source.Parent.Bsp != null) {
|
||||
Data = new byte[GetStructLength(source.Parent.Bsp.version, source.Parent.LumpInfo.version)];
|
||||
} else {
|
||||
Data = new byte[GetStructLength(MapType.Undefined, 0)];
|
||||
}
|
||||
}
|
||||
|
||||
PlaneIndex = source.PlaneIndex;
|
||||
TextureIndex = source.TextureIndex;
|
||||
FaceIndex = source.FaceIndex;
|
||||
DisplacementIndex = source.DisplacementIndex;
|
||||
IsBevel = source.IsBevel;
|
||||
IsThin = source.IsThin;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Factory method to parse a <c>byte</c> array into a <see cref="Lump{BrushSide}"/>.
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user