Does Direct3D overload System.Math??

  • Thread starter Thread starter Ark
  • Start date Start date
A

Ark

Hi everyone,

Does anyone know if Direct3D overloads System.Math
functions?

Also is it possible to access the base functions of the
overloaded function (in other words restore original of
the overlaoded function)?

Thank you

ARK
 
Hi Ark,

I believe "overload" should read "override". If this is so, you cannot alter
how the method is implemented in the base class - you can only provide
alternative implementation in the inherited one. So, if you need to access
the base implementation, just up-cast a reference to the System.Math type
and use the up-casted reference to invoke the methods.

Still, as far as I remember, the Math methods are mostly static and
therefore cannot be overridden. Direct3D provides its own subset of math
functions for matrices and vectors - but it's unlikely they have something
to do with the .NET's System.Math.
 
Ark said:
Does anyone know if Direct3D overloads System.Math
functions?

Also is it possible to access the base functions of the
overloaded function (in other words restore original of
the overlaoded function)?

It's fairly unclear what you're meaning here - could you give an
example, indicating why you think Direct3D is altering System.Math
behaviour? It sounds unlikely to me.
 
Hi Dmitriy and everyone,

Thank you for your prompt reply. Can you please give me an example of
how to up-cast the methods as you described in your reply?

Here is a more detailed description of the problem I am experiencing. I
wrote and application that uses Direct3D to render the mechanism. To
drive the mechanism i use complex 6D numerical algorithm that uses
System.Math to get solutions. Both graphical and mathematical parts work
fine separately. However when i want to run graphical interface and
numerical engine in parallel in a single application I get the following
problem:

The System.Math starts to behave in a wired way, round function does not
work well/at all. If I try to round to two decimal places, it rounds to
13, when I try to print the rounded number to console it prints the
number with 13 decimal places rather than two. Also the actual math is
performed at a very slow rate.
If I can compile both applications separately ( as independent
executables) all works fine, simultaneously.

I tired to backtrack what causes the problem, and apparently the problem
comes once create the d3d device is executed:

// Create the device
device = new Device(graphicsSettings.AdapterOrdinal,
graphicsSettings.DevType, windowed ? RenderTarget : this , createFlags,
presentParams);

To write Direct3D engine, i directly adopted example 'Enhanced Mesh'
provided by DirectXSDK.

I think something happens to memory or to resources, but not sure about
it. Even if i dipose the device after it was created the problem is
still present. Also when I move the mouse over the function Round (after
typing Math.) it say in part of the hint text +3 overloads. So my
suspicion is that direct3d in some way affects system math and that some
functions are executed in different way.

Any ideas what is going wrong here, or how to easily isolate the two
parts to avoid all this?

Thanks,

ARK
 
Ark said:
Hi everyone,

Does anyone know if Direct3D overloads System.Math
functions?

Also is it possible to access the base functions of the
overloaded function (in other words restore original of
the overlaoded function)?

Thank you

ARK

Haven't encountered that untill now. Even if it does, it only can
overload the method with different parameters or hide it in a derived
class. This is because System.Math is a class with static members and
not a namespace. Both would be visible to you right away by the new
class scope. So a call to System.Math.Acos will go exactly to that
method.
HTH,
Andy
 
I haven't heard of or seen this behavior before but I do know that the
default behavior of DirectX is to change the floating point precision.
Could this be part of your problem?
 
Back
Top