Jump to content

Recommended Posts

Posted

I want to use the force parameter from Collisioncallback.

But it is passed as Byte Ptr. How do I get the force as Tvec3?

Core2DuoE6570 / Windows7 64bit / 4 Gb RAM / Geforce GTX 260 896Mb / LE 2.3

Dell Inspiron 1720 / Vista SP2 / C2D 2.4 / 8600 GM

Posted

Probably something like this would work, but it seems like a good idea to add this to mathlib:

void _stdcall EntityCollisionCallback( TEntity entity0, TEntity entity1, byte* position, byte* normal, byte* force, flt speed )
{
TVec3 hitforce;
hitforce.X=force[0];
hitforce.Y=force[4];
hitforce.Z=force[8];
}

Ryzen 9 RX 6800M ■ 16GB XF8 Windows 11 ■
Ultra ■ LE 2.53DWS 5.6  Reaper ■ C/C++ C# ■ Fortran 2008 ■ Story ■
■ Homepage: https://canardia.com ■

Posted

void _stdcall EntityCollisionCallback( TEntity entity0, TEntity entity1, byte* position, byte* normal, byte* force, flt speed )
{
TVec3 hitforce;
hitforce.X=force[0];
hitforce.Y=force[4];
hitforce.Z=force[8];
}

 

Ehm, you mean I should use C++ code in Blitzmax?

 

The most of the EntityCollisionCallback parameters seem to be pretty useless if I can't get them in an usable format for Blitzmax.

Core2DuoE6570 / Windows7 64bit / 4 Gb RAM / Geforce GTX 260 896Mb / LE 2.3

Dell Inspiron 1720 / Vista SP2 / C2D 2.4 / 8600 GM

Posted

Well, you can use C++ code in BlitzMax, but that's not the point here now.

BlitzMax should have a similar method to construct a foreign type from pointers, like in the C++ example I showed.

Indeed, Josh started to use those wierd [] operators for float arrays some time ago, so instead of saying Vec3(1,2,3) he says [1,2,3]. So I think the Byte Ptr problem could be easily solved using the fact that Vec3 is just an array of 3 subsequent float (4 byte) values.

Ryzen 9 RX 6800M ■ 16GB XF8 Windows 11 ■
Ultra ■ LE 2.53DWS 5.6  Reaper ■ C/C++ C# ■ Fortran 2008 ■ Story ■
■ Homepage: https://canardia.com ■

Posted

Probably something like this would work, but it seems like a good idea to add this to mathlib:

void _stdcall EntityCollisionCallback( TEntity entity0, TEntity entity1, byte* position, byte* normal, byte* force, flt speed )
{
TVec3 hitforce;
hitforce.X=force[0];
hitforce.Y=force[4];
hitforce.Z=force[8];
}

Why so complicated?

TVec3 *pHitForce = reinterpret_cast<TVec3*>(force);

Posted

I am not sure why I chose to use byte ptrs in BlitzMax. A Vec3 makes more sense to me, don't you think?

My job is to make tools you love, with the features you want, and performance you can't live without.

Posted

Fortunately if I change this, any code that worked with byte ptrs should work with vec3 objects as well.

My job is to make tools you love, with the features you want, and performance you can't live without.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...