Notifications
Clear all

[Closed] Useful mxs sdk extension functions

 have you tried:

      for (int i = 0; i < vl.indexes->size; i++) vl.indexes->data[i] = Integer::intern(i+1);   
     

also i found that array->append methods eats memory

it’s tricky there are other things that need to be set, the data is kept as some kind of linked list.

1 Reply
(@denist)
Joined: 11 months ago

Posts: 0

do you mean putting values in data is the same slow as append?

just got round to trying it and it seems to work ok.

just a quick note on the max heap stl allocator I posted above. It seems to work without issue in any other type of plugin… some more cryptic implementations as follows…

typedef basic_string<char, char_traits<char>, MaxAlloc<char>> max_stl_string;
typedef map<max_stl_string, int, less<max_stl_string>, MaxAlloc<pair<const max_stl_string, int>>> Str2IntMap;

can’t codify as cgsocieties encoder can handle the finer points of templates

the code creates a string to int lookup table with all the memory allocation from max’s application heap.

a slightly off the wall one here… check to see if a directx hlsl/fx shader is GetIGameFX safe. there’s a problem that the IGame fx parser (or what ever it uses) is much more picky than the default max dx material one, so an apparently correct and working shader i.e. working correctly and not the red wire frame of doom ! will fall foul of the function…

always returning NULL.

so heres a function that will test the material returning true if igame safe…

also requires the igame.lib added to linker dependencies…

some errors that I know that can cause it to fail…

keywords…

technique is correct
Technique will fail

Texture (in a sampler definition pipe state) is correct
texture will fail
as opposed to…
texture as property definition is correct
Texture will fail

a “;” in a string definition will cause a fail

mirror of the polyop variant in returning the vert indices as an array, i know you can iterate through a point3 but you can’t use join or convert to a bitarray (not with out additional code
anyway )

have you tried:
Code:
[left] for (int i = 0; i < vl.indexes->size; i++) vl.indexes->data[i] = Integer::intern(i+1); [/left]

also i found that array->append methods eats memory

there is still an issue doing that way in the above example…

ends up with a == b ! (which is wrong) but using the append variation a != b

returns a material preview as a max bitmap
sz = 0 -> 32×32
sz = 1-> 88×88
sz > 1->24×24

found and interesting ray mesh intersection function hidden in the sdk, tried it out as a mxs extension function, runs about 6 times faster than the native version, enjoy…

some more on performance

completely “random” ray on a object with back facing faces ~6x
always colliding ray on a object with back facing faces ~4x
always colliding ray on a plane ~2-4x

1 Reply
(@denist)
Joined: 11 months ago

Posts: 0

as i can see your function returns the first face that was intersected… but the built-in method returns the closest one. if you continue search intersected faces and finally find the closest hit, it will change the performance.

Page 10 / 18