int calculateThing(int i1, int i2);
int calculateThingFast(int i1, int i2);
inline int calculateThingFast(int i1, int i2)
{ ***blahblahblah*** }
int calculateThing(int i1, int i2)
{ return calculateThingFast(i1, i2); }
Now, assuming that the compiler actually inlines the function properly (not sure how to check on that, if anyone knows how to make sure it does actually inline the function please let me know), I will be able to inline the function where needed and call it normally where needed. By the way, if anyone knows a better way to do this, by all means let me know.
Anyway, I've written an infinite plane cut class using inlined line-test functions, which curently tests edges against a plane (it is also capable of figuring out if the ends of the edges are exactly on the plane, which I will need later). Here's some sample images. The plane is represented by a square with a red dot representing the center (or a point on the plane) and a fading line representing the normal. Since the plane is of infinite size, the size of the square is not relevant.



So some progress is happening, next I want to work on a finite, circle-shaped cut, then a convex polygon cut. Once that is done, the next step is to start handling the different possible cuts, then triangle sorting, new face generation, handling transforms etc. Of course in the long run it has to be integrated with the model format rather than the current simple mesh, as well as needing to work properly with the animation system (a problem I never solved in the past) which doesn't even exist yet... basically it's going to take a while, and I'm busier than ever now. Still, I shall try to keep at it. Wish me luck.
Hmm, I have to ask: why would you call the more expensive "normal" function when you could just call the inline function? What are the benefits of having a "normal" equivalent of an inline function? I can't think of any. Surely it just means more work for you?
ReplyDeleteHey, sorry for the late reply, been very busy. Since inlined functions are copied into the code every place that they are called, they increase code size. Increasing code size can make the program slower, so you have to be careful. Functions are usually inlined only when they are very small or used in very few places. The functions I was writing were quite large and might be needed in many places so would not normally be inlined, but in a few places I needed them to be very fast, so it was better to have them inlined in just those places. Thus the advantages of having both versions, and since the non-inlined version just calls the inlined version it's not all that much extra work or complication.
ReplyDeleteI'm sorry if I sound condescending or anything, I really don't mean to, I just can't tell how much you know about programming so I'm trying to be very clear.