Skip to main content
gamedev.net
🔒 Locked 🎮 Unity

Vector3::Project

Started by BeanDog Sep 21, 2005 at 10:25 PM 2 replies 900+ views
Original Post
BeanDog
BeanDog
I'm using DirectX9 Managed. I'm using Vector3::Project, but I'm doing it hundreds or thousands of times per frame. It's seriously sucking down some CPU time. The function takes as parameters all the transform matrices of the device. Is there some kind of batch call I can make? Or, alternatively, is there a way to get the final resulting matrix from all the transforms the device does so that I can apply a single matrix multiplication to each vector? I've tried simply multiplying world * view * projection, and it doesn't seem to give me the right answers. Thanks, ~BenDilts( void );
Bosh
Bosh
Isn't there some kind of Device.processvertices method (Device::ProcessVertices)?
Armadon
Armadon
Hi there BeanDog,
How are you doing?

The Problem
Vector3.Project function alternatives.

The Solution
There are a couple of things you could do if you are finding Vector3.Project to be slow which I highly doubt as these functions are optimized to deliver good performance.

1) You could opt to write your own projection function which you can do by transforming your vectors from object space to screen space by multiplying the world, view and projection matrices by each other and doing the math behind transforming your vectors by that resulting matrix.

2) You could also implement a timer, this has a few problems though as one main concern is precision as you will not be performing the project each frame and in the event that you are using it to check collision, picking etc.. you might miss a selection/picking/collision.

I hope this helps a bit, if you can maybe supply us with some stats we might advice you as to what tolerance would be correct.

PS: Are you sure it's the Vector3.Project that's the problem,
Make sure you are using a resource friendly loop, if you are using the Application.DoEvents() loop you might want to look over at Tom Miller's blog for a resource friendly loop.

Take care bud.
BeanDog
BeanDog
Armadon: Thanks for the extra-friendly reply, but I have to give Bosh rating++ for giving me exactly the answer I was looking for.

Thanks everyone!



~BenDilts( void );

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.