Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

1411275 Posts in 69323 Topics- by 58380 Members - Latest Member: bob1029

March 28, 2024, 08:00:16 AM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsDeveloperTechnical (Moderator: ThemsAllTook)The grumpy old programmer room
Pages: 1 ... 222 223 [224] 225 226 ... 295
Print
Author Topic: The grumpy old programmer room  (Read 733245 times)
fractilegames
Level 1
*



View Profile WWW
« Reply #4460 on: February 16, 2014, 05:05:23 AM »

I finished implementing a force field system for my game. Now that it's finally done, I realized it's way too complicated and confusing for the player!

I have to redo it almost from scratch. I should have kept it simple..
Logged

Eendhoorn
Level 6
*

Quak


View Profile
« Reply #4461 on: February 22, 2014, 07:28:51 PM »

I just spent the last two hours trying to figure out why the hell this angle (degrees) to vector2 conversion is not working.

angle:
Code:

public static Vector2 AngleToV2(float angle)
{
return new Vector2(Mathf.Cos(angle), Mathf.Sin(angle));
}


Should be simple enough, but it returns these results;

Angle: 47.75935
Correct vector: (0.6, 0.7)
AngleToV2 vector: (-0.8, -0.6)

Angle: 90
Correct Vector : (0.0, 1.0 )
AngleToV2 vector: (-0.4, 0.9)


Arghhhhh. I'm using unity btw, where y- is down and y+ is up.
I'm probably doing something super stupid.
Logged

apookapus
Level 0
*


View Profile
« Reply #4462 on: February 22, 2014, 07:44:26 PM »

I just spent the last two hours trying to figure out why the hell this angle (degrees) to vector2 conversion is not working.

Passing degrees to functions that expect radians, I think.
Logged
rosholger
Level 1
*



View Profile
« Reply #4463 on: February 22, 2014, 07:46:20 PM »

as apookapus said, you are passing degrees to functions that expects radians, just multiply the angle with 0.0174532925 and you will get the expected result
Logged
Eendhoorn
Level 6
*

Quak


View Profile
« Reply #4464 on: February 23, 2014, 11:56:27 AM »

I could've sworn I already tried that, guess it was late. Thanks guys, it working perfectly now.
Logged

Fallsburg
Level 10
*****


Fear the CircleCat


View Profile
« Reply #4465 on: February 23, 2014, 02:03:50 PM »

as apookapus said, you are passing degrees to functions that expects radians, just multiply the angle with 0.0174532925 and you will get the expected result

bad magic number, bad.  Define some sort of DEGREES_TO_RADIANS or do an inline DegreesToRadians function (FYI, degrees to radians is PI/180 and radians to degrees is 180/pi).
Logged
rosholger
Level 1
*



View Profile
« Reply #4466 on: February 23, 2014, 03:53:41 PM »

as apookapus said, you are passing degrees to functions that expects radians, just multiply the angle with 0.0174532925 and you will get the expected result

bad magic number, bad.  Define some sort of DEGREES_TO_RADIANS or do an inline DegreesToRadians function (FYI, degrees to radians is PI/180 and radians to degrees is 180/pi).

yeah i know but, i didn't mean "insert this magic number" was more of a "this is the magic number, you should put it somewhere safe where it makes sense"
Logged
Geti
Level 10
*****



View Profile WWW
« Reply #4467 on: February 23, 2014, 03:59:48 PM »

I saw so mad last Friday that I just ignored the internet for a few days. Did a search for .orig and deleted the results. Michal had added one of his .orig files to mercurial. I ended up deleting a meta file and breaking my repo, wasting 2 hours from 1230 to 230 am fixing that shit so I could push. Not a great end to the week.
Logged

Garthy
Level 9
****


Quack, verily


View Profile WWW
« Reply #4468 on: February 23, 2014, 04:19:13 PM »

C++.

Ran into an error caused by a missing bracket that raised the error at the end of file. No further information available. I'm sure almost everyone has run into that at some point? They're tricky to find, aren't they?

Try doing it when the missing bracket is caused by an issue somewhere in approximately fifty thousand lines of automatically generated source that cannot be disabled as it raises dozens of errors elsewhere without it, and occurs across a seemingly random set of files, while working with an incomplete feature set with hooks into multiple files that triggers constant false positives.

Spent over two demoralising hours searching for a single missing bracket without success. I then wrote a script to scan files for bracket counts and highlight any suspicious files, which I then checked manually and eventually found the cursed bug.

Close to three hours tracking down a single bracket in a language I have considerable expertise with.
Logged
Geti
Level 10
*****



View Profile WWW
« Reply #4469 on: February 23, 2014, 04:47:44 PM »

Sounds like that could have been helped by rolling back a version and trying again. Condolences for the hellish bug hunt though.
Logged

Garthy
Level 9
****


Quack, verily


View Profile WWW
« Reply #4470 on: February 23, 2014, 05:17:51 PM »

Sounds like that could have been helped by rolling back a version and trying again. Condolences for the hellish bug hunt though.

A good suggestion, but a few things were working against me: I didn't want to lose the partly-written code since my last checkin, so that option was out. At the time I did not want to decouple the code, revert to known working, and reimplement it a piece at a time because it seemed overkill compared to finding a single bracket. Of course, had I known right at the start how long finding that bracket would take, I would have done this instead and saved considerable time. Sad And lastly, it appeared that the last checkin also contained the bug, so I could not count on it. This turned out to be incorrect, but I only determined this after locating the bug.

On the bright side, my existing character counting script now has a bracket matching option that should prove helpful with similar problems in the future.
Logged
Will Vale
Level 4
****



View Profile WWW
« Reply #4471 on: February 23, 2014, 07:35:03 PM »

I ended up deleting a meta file and breaking my repo, wasting 2 hours from 1230 to 230 am fixing that shit so I could push. Not a great end to the week.

Oh no, I did that a few weeks ago as well - exactly the same situation, cleaning up a couple of rogue .orig files via search and inadvertently deleting some in .hg Sad

Took quite a while locating replacement .orig files from a second copy of the repo...  WTF

Logged
Geti
Level 10
*****



View Profile WWW
« Reply #4472 on: February 23, 2014, 07:57:58 PM »

I just had to clone from a "safe" revision, pull remote again, manually paste in my changes and then commit anew, but it took ages to actually get to the point that I knew that (and I was determined to "save" it even though that was hopeless).
Logged

George Michaels
Level 0
***


I like big butts and I can not lie


View Profile
« Reply #4473 on: February 25, 2014, 12:05:57 AM »

I left my project to move house 3 times in 3 weeks and forgot where I was up to.

Apparently it was the collision detection code  Lips Sealed

Logged

Yeah, that.
Geti
Level 10
*****



View Profile WWW
« Reply #4474 on: February 25, 2014, 01:44:10 AM »

You'll get it Smiley Simple collisions aren't hard, it's proper dynamics where everything gets ugly (and also of questionable gameplay value).
Logged

Garthy
Level 9
****


Quack, verily


View Profile WWW
« Reply #4475 on: February 25, 2014, 04:02:45 PM »

I left my project to move house 3 times in 3 weeks and forgot where I was up to.

Apparently it was the collision detection code  Lips Sealed



That made me laugh. :D I do stuff like that too, especially when I've been caught up in other things and I haven't yet had a chance to get back to properly finish something off.
Logged
Eendhoorn
Level 6
*

Quak


View Profile
« Reply #4476 on: February 25, 2014, 07:15:12 PM »

Talking about collision detection, why the fuck does unity's "OnCollisionEnter2D" function get's called AFTER collision forces are applied. I can really see the charms of open source in times like this.
Logged

kazak
Level 0
**


formerly saintgutfree


View Profile
« Reply #4477 on: February 26, 2014, 06:56:10 PM »

do you guys ever scan through your code 50 times looking for the error without success and keep executing it anyway because IT SHOULD FUCKING WORK?
Logged
Geti
Level 10
*****



View Profile WWW
« Reply #4478 on: February 26, 2014, 08:21:00 PM »

Yeah I was actually doing that last night. Woke up this morning and fixed the issue without a pause, haha. Tired brains are angry brains
Logged

Garthy
Level 9
****


Quack, verily


View Profile WWW
« Reply #4479 on: May 08, 2014, 03:34:49 AM »


Wow, not many grumpy people lately. Wink I guess everyone's projects are going well.

So, I'm digging around some code that I need to run faster as it is impairing my development speed. I identify a particular object in my code, which is designed with a great deal of flexibility, and quite reliant on that flexibility. However, this is an object that is effectively used in an inner loop, and the flexibility is killing performance.

I'm able to determine that the non-core flexibility is used perhaps less than 1% of the time, but in that case, the flexibility is absolutely required. I come up with a theoretical solution: Split the object in two- a fast part, and a slow part. The fast part is something I should be able to speed up considerably- based on profiling I am suspecting almost a 2x or 3x speedup is possible- very significant. The slow part would be generated on-demand, with perhaps a 2x or 3x slowdown when using it, since it is no longer tightly integrated with the core code. Still, it's worthwhile- 2-3x speedup in 99% of cases versus a slowdown in 1% of cases. Easy net gain- still around 2.5x speedup. But very tricky to code, the existing codebase assumes that the object will remain flexible.

Roughly forty hours of development time later, much of it very tedious, with several extremely clever solutions to cover interesting corner cases, I have a version that implements my initial vision which passes my test suite fully. I'm ready to flip the switch: I set up an optimised build, and time the code to see what sort of improvement I obtained. I make a bet with myself that the code will now run about 2x as fast, but i would not be surprised to see it run at 3x. The results come in:

Net speedup: 7%

NOOOOOOOOOOOOOOOOOOOOOOOO! Cry

I confirm it's all working, and that indeed the flexible object is needed less than 1% of the time as I had estimated. It's just that the optimisations to the core object gave only simple gains. My estimate for the gain was off by a huge margin.

I spend an hour and a half afterward making some simple optimisations to unrelated parts of the code, such as using pointers rather than offsets, replacing some dynamic casts with virtual calls, and eliminating some inner-loop "ifs" by making some changes outside of the loop. Nothing complex, no real planning.

Net speedup: 5%

I spent forty solid, tedious hours getting only slightly greater gains than I would have by spending a couple of hours making some simple, small, unplanned, ad hoc changes. FML.

Logged
Pages: 1 ... 222 223 [224] 225 226 ... 295
Print
Jump to:  

Theme orange-lt created by panic