如何将此C++代码片段转换为C#?将“const float *”从C++翻译为C#
void fm_getAABB(..., const float *points, ...)
{
// ...
const unsigned char *source = (const unsigned char *) points;
//...
const float *p = (const float *) source;
//...
}
我已经试过使用C++ to C# converter,但它似乎无法翻译它。
编辑:
这里的整体功能:
void fm_getAABB(unsigned int vcount, const float *points, unsigned int pstride,
float *bmin, float *bmax)
{
const unsigned char *source = (const unsigned char *) points;
bmin[0] = points[0];
bmin[1] = points[1];
bmin[2] = points[2];
bmax[0] = points[0];
bmax[1] = points[1];
bmax[2] = points[2];
for (unsigned int i = 1; i < vcount; i++)
{
source+=pstride;
const float *p = (const float *) source;
if (p[0] < bmin[0]) bmin[0] = p[0];
if (p[1] < bmin[1]) bmin[1] = p[1];
if (p[2] < bmin[2]) bmin[2] = p[2];
if (p[0] > bmax[0]) bmax[0] = p[0];
if (p[1] > bmax[1]) bmax[1] = p[1];
if (p[2] > bmax[2]) bmax[2] = p[2];
}
}
C#不使用指针。你应该重写它。 – SLaks
像往常一样,解决方案包括:获得对两种语言的理解;获得对原始代码的理解;使用这种理解来编写所需的代码。 –
我有一些C++语言的基本知识,但在这个特定的情况下,我完全失去了。 –