I am communicating between two libraries which use equivalent structs. For example:
struct MyVector {
public float x, y, z;
}
struct TheirVector {
public float x, y, z;
}
Currently I am "casting" between these types by copying each of one's members into an instance of the other. Knowing how C# stores structs in memory, isn't there a much more efficient way of doing this with pointers?
Additionally, let's say I have two arrays of these equivalent structs:
MyVector[] array1; // (Length 1000)
TheirVector[] array2; // (Length 1000)
Isn't there a way to copy the whole block of memory from array1 into array2? Or even better, could I treat the entirety of array1 as of type array2 without creating a copy in memory?
I'm sure the answer requires pointers, but I have only used pointers in C++ and have no idea how C# implements them.
Does anyone have any examples on how to achieve something like this?
Thanks in advance!