> Taken > > But in this particular case, being heavy matrix opreations in > 3d, this kills your performance.
If you want performance, write a shader and do your matrix manipulations on the GPU or call into a C++ matrix lib. I also don't really see why classes would kill performance really. Admitted, in C++ I used structs for coordinates and some own written math lib for working with those structs, however a struct is a class in C++ anyway (they're synonyms, IIRC) so why would: public class Vertex3 { public float X; public float Y; public float Z; } be slow in .NET? Graphic programming can only be done fast if you parallellize operations by delegating the tasks to specialized units, often a library written to do a given kind of operation really fast (optimized math lib) or for example a DX helper lib, or better: a shader which does manipulation of your data down the pipe in hardware. I don't think 3D vector math in C# will be that performant over a C++ version. And in the end, if you insist doing the math in C#, you can of course fall back to the good old days method when we all used assembler: 3 arrays of floats or a 3 dim. array of floats. Do your math in place and convert it to an array of vertex objects to send it down the pipe to the hardware. But if you ask me, see the .NET layer in a DX program which relies heavily on graphics performance as a thin layer to keep the program together, not the core application: the power is not in the .NET layer, it's in the DX layer so don't try to do more in the .NET layer than absolutely necessary. > Purity is nice, but here we talk of criticals, too. if performance is critical, use the right objects in the layer-stack to do the work :) So, I'd suggest to call into C++ math libs from C# and pass on the result to DX, or better: write a shader. Much faster :) FB > > Thomas Tomiczek > THONA Software & Consulting Ltd. > (Microsoft MVP C#/.NET) > (CTO PowerNodes Ltd.) > > > -----Original Message----- > > From: Unmoderated discussion of advanced .NET topics. > > [mailto:[EMAIL PROTECTED] On Behalf Of > Frans Bouma > > Sent: Montag, 17. Mai 2004 10:00 > > To: [EMAIL PROTECTED] > > Subject: Re: [ADVANCED-DOTNET] Large structures > > > > > I think the main issue here is that teh DirectX API (which > > this was > > > about in the beginning) does not pass the structy by ref. > > > > > > Looks like a tremendous oversight to me. > > > > > > The rest then is basically a logical extension of standard .NET > > > semantics (structs copied onto stack) and not perfect > optimizations > > > (that are also not really wanted). > > > > > > Has anyone a clue whether there may be a reason they are > > not defined > > > as ref? > > > > Because the DX api is a COM api, which works with > objects and > > pointers, something you can mimic with classes in C# and > references to > > objects. Structs in .NET should, correct me if I'm wrong, > be used to > > create somewhat specialized value types, like a > 'Coordinate', and then > > also just for .NET, not for COM interop. > > > > Because there are some drawbacks on structs, like > manipulating > > them in a boxed situation (array list for > > example) is cumbersome, it's IMHO best to use classes instead of > > structs, especially when it comes to DX interop. > > > > FB > > > > =================================== > > This list is hosted by DevelopMentor(r) > http://www.develop.com Some > > .NET courses you may be interested in: > > > > NEW! Guerrilla ASP.NET, 17 May 2004, in Los Angeles > > http://www.develop.com/courses/gaspdotnetls > > > > View archives and manage your subscription(s) at > > http://discuss.develop.com > > > > > > =================================== > This list is hosted by DevelopMentor(r) http://www.develop.com > Some .NET courses you may be interested in: > > NEW! Guerrilla ASP.NET, 17 May 2004, in Los Angeles > http://www.develop.com/courses/gaspdotnetls > > View archives and manage your subscription(s) at > http://discuss.develop.com > > > > =================================== This list is hosted by DevelopMentor® http://www.develop.com Some .NET courses you may be interested in: NEW! Guerrilla ASP.NET, 17 May 2004, in Los Angeles http://www.develop.com/courses/gaspdotnetls View archives and manage your subscription(s) at http://discuss.develop.com