• What are you working on? February 2012
    3,497 replies, posted
  • [QUOTE=DeadKiller987;34774974]Link us. I bet it's hilarious.[/QUOTE] It's not. [quote][B]We're looking for:[/B] Microsoft .NET (C#, VB) WPF, XAML Java / C++ Databases, SQL[/quote]
  • I try really hard not to waste everyone's time here by copy-pasting stuff from some of the stupid classes I take, but I thought this one was pretty funny: [quote]Which search technique is commonly used for searching in pathfinding and navigation algorithms in video games? (Points : 10) A+ A* A$ A- None of the above.[/quote] Also while I'm at it: [quote]7. The order of a postorder traversal of a binary search tree. (Points : 3) [/quote] Is that even a question?
  • [QUOTE=swift and shift;34783033]are you serious [editline]20th February 2012[/editline] so this is essentially what the assembly posted by tobba does: [cpp] struct foo { int a; int b; }; int get_b(struct foo* ptr) { int b = ptr->b; return b; } [/cpp] with [b]no[/b] optimization, this is what gcc does: [code] _get_b: push ebp mov ebp, esp sub esp, 0x18 mov eax, [ebp+0x08] mov eax, [eax+0x04] mov [ebp+0xf4], eax mov eax, [ebp+0xf4] leave ret [/code] at -fomit-frame-pointer -O3, this is what gcc does: [code] _get_b: mov eax, [esp+4] mov eax, [eax+4] ret [/code] that's as compact as you can get without inlining (which gcc does anyway)[/QUOTE] (I really have no idea if this idea would make any sence) But does that mean if you let gcc run over skyrims bin's then you could end up with a ~faster~ game.
  • [QUOTE=benjojo;34783754](I really have no idea if this idea would make any sence) But does that mean if you let gcc run over skyrims bin's then you could end up with a ~faster~ game.[/QUOTE] You'd need the source, after you have the binaries the damage is already done. And I doubt it would be faster.
  • [QUOTE=Darwin226;34783778]You'd need the source, after you have the binaries the damage is already done. [B]And I doubt it would be faster[/B].[/QUOTE] Why?
  • [QUOTE=Robber;34784043]Why?[/QUOTE] it would probably not even run, optimisations are always a bit critical, sometimes they lead to invalid code and bugs due to faulty optimisation are extremely difficult to track down. Also a few instructions more or less don't always make much of a difference, most of the load is on the graphics card anyway so i doubt you'd have any notable performance increase
  • [QUOTE=Kamshak;34784114]it would probably not even run, optimisations are always a bit critical, sometimes they lead to invalid code and bugs due to faulty optimisation are extremely difficult to track down. Also a few instructions more or less don't always make much of a difference, most of the load is on the graphics card anyway so i doubt you'd have any notable performance increase[/QUOTE] i'm sure if you patched out that particular function with some other code (and padded out the rest of the function after ret to keep the same size) it'd work fine whether you'd see any perf gains is a different story
  • [QUOTE=dajoh;34782395]If I understand you correctly, you want to be able to do something like this: Push Clipping Region (100,100,200,100) (x,y,w,h) Push Clipping Region (25,25,50,10) (new real clipping region is 125,125,50,10) Pop Clipping Region (new real clipping region is 100,100,200,100) If so, all you need to do is create a class with push/pop methods to apply the new clipping region every time you use them.[/QUOTE] I can get the world position of panels, and I have a push/pop method that is ready to have some code put into it. But look, here is the problem with your method: I can't have subpanels clip and their parents with a different clip. That's why I can't just use g.setWorldClip, because you can't "stack" the clips.
  • [QUOTE=icantread49;34781584]so i ran across a very odd crash in box2d every once in a while but i didn't really think much of it today, i decided to crack down on it, thinking that i've been misusing box2d turns out i ran across some obscure bug that only a handful of other people encountered, and i found exactly one thread about it, and erin posted an unexplained code snippet there that fixes it glad to know it wasn't my fault :v:[/QUOTE] [img]http://imgs.xkcd.com/comics/wisdom_of_the_ancients.png[/img]
  • [QUOTE=Map in a box;34785344]I can get the world position of panels, and I have a push/pop method that is ready to have some code put into it. But look, here is the problem with your method: I can't have subpanels clip and their parents with a different clip. That's why I can't just use g.setWorldClip, because you can't "stack" the clips.[/QUOTE] Are you trying to say that clipping only applies to the final raster?
  • [QUOTE=Downsider;34785628]Are you trying to say that clipping only applies to the final raster?[/QUOTE] If I understand you right, yes. I can only use 1 clip. I'll make a bug report to avoid using OpenGL(seems more hacky than its worth)
  • [QUOTE=Map in a box;34785344]I can get the world position of panels, and I have a push/pop method that is ready to have some code put into it. But look, here is the problem with your method: I can't have subpanels clip and their parents with a different clip. That's why I can't just use g.setWorldClip, because you can't "stack" the clips.[/QUOTE] That's why you keep track of clips using a stack like Dajoh said. Here's a really quick example I wrote up in lua: [lua] local clip = {stack = {{x =0, y = 0, w = 3000, h = 3000}}, current = {x =0, y = 0, w = 3000, h = 3000}} function clip.push(x, y, w, h) local c = clip.current -- If the new region is smaller in any way than the old region, compress the current region to fit. if(x + w < c.x + c.w) then c.w = w end if(y + h < c.y + c.h) then c.h = h end if(x > c.x) then c.x = x end if(y > c.y) then c.y = y end table.insert(clip.stack, {x = x, y = y, w = w, h = h}) end function clip.pop() if(#clip.stack <= 0) then return end -- Remove the "current" stack table.remove(clip.stack, #clip.stack) local c = clip.current local o = clip.stack[#clip.stack] -- If the old region on the stack is bigger in any way, expand the relevant component to fit. if(o.x + o.w > c.x + c.w) then c.w = o.w end if(o.y + o.h > c.y + c.h) then c.h = o.h end if(o.x < c.x) then c.x = o.x end if(o.y < c.y) then c.y = o.y end end function clip.getRegion() return clip.current.x, clip.current.y, clip.current.w, clip.current.h end -- Tests print("start: ", clip.getRegion()) clip.push(10, 10, 200, 200) print("push: ", clip.getRegion()) clip.push(50, 10, 50, 200) print("push: ", clip.getRegion()) clip.push(10, 70, 200, 130) print("push: ", clip.getRegion()) clip.pop() print("pop: ", clip.getRegion()) clip.pop() print("pop: ", clip.getRegion()) clip.pop() print("pop: ", clip.getRegion()) [/lua] It outputs this, which is the expected output. It's basically the smallest possible region that doesn't expand beyond any of the given points. [code] lua clip.lua start: 0 0 3000 3000 push: 10 10 200 200 push: 50 10 50 200 push: 50 70 50 130 pop: 50 10 50 200 pop: 10 10 200 200 pop: 0 0 3000 3000 [/code]
  • Progress on my stab at rendering an image as text! After some modifications and working it through to find the issue with the colouration, I have managed to turn this: [IMG]http://dl.dropbox.com/u/38489921/test3.png[/IMG] Into this: [IMG]http://dl.dropbox.com/u/38489921/image.png[/IMG] Right now, the only character it writes in is +'s, and there is an inevitable smoothing issue due to the way I am doing it. When I process a coloured striped image similar to the test above, I only get half of the image processed...so I've gotta find out why. Next stages are implementing a character set and refining the method to produce a more detailed and accurate representation of the colours in a processed image. For anyone who is interested, [URL="http://pastie.org/3420457"]here's the source[/URL] :)
  • [QUOTE=Dr Magnusson;34785675]That's why you keep track of clips using a stack like Dajoh said. Here's a really quick example I wrote up in lua: [lua] local clip = {stack = {{x =0, y = 0, w = 3000, h = 3000}}, current = {x =0, y = 0, w = 3000, h = 3000}} function clip.push(x, y, w, h) local c = clip.current -- If the new region is smaller in any way than the old region, compress the current region to fit. if(x + w < c.x + c.w) then c.w = w end if(y + h < c.y + c.h) then c.h = h end if(x > c.x) then c.x = x end if(y > c.y) then c.y = y end table.insert(clip.stack, {x = x, y = y, w = w, h = h}) end function clip.pop() if(#clip.stack <= 0) then return end -- Remove the "current" stack table.remove(clip.stack, #clip.stack) local c = clip.current local o = clip.stack[#clip.stack] -- If the old region on the stack is bigger in any way, expand the relevant component to fit. if(o.x + o.w > c.x + c.w) then c.w = o.w end if(o.y + o.h > c.y + c.h) then c.h = o.h end if(o.x < c.x) then c.x = o.x end if(o.y < c.y) then c.y = o.y end end function clip.getRegion() return clip.current.x, clip.current.y, clip.current.w, clip.current.h end -- Tests print("start: ", clip.getRegion()) clip.push(10, 10, 200, 200) print("push: ", clip.getRegion()) clip.push(50, 10, 50, 200) print("push: ", clip.getRegion()) clip.push(10, 70, 200, 130) print("push: ", clip.getRegion()) clip.pop() print("pop: ", clip.getRegion()) clip.pop() print("pop: ", clip.getRegion()) clip.pop() print("pop: ", clip.getRegion()) [/lua] It outputs this, which is the expected output. It's basically the smallest possible region that doesn't expand beyond any of the given points. [code] lua clip.lua start: 0 0 3000 3000 push: 10 10 200 200 push: 50 10 50 200 push: 50 70 50 130 pop: 50 10 50 200 pop: 10 10 200 200 pop: 0 0 3000 3000 [/code][/QUOTE] The children need to be clipped to the parents, too.
  • [QUOTE=Map in a box;34785865]The children need to be clipped to the parents, too.[/QUOTE] Then push the panel's clipping region as you traverse down the chain of panels as you draw them. [lua] function Panel:draw() clip.push(self.x, self.y, self.w, self.h) g.setClipRegion(clip.getRegion()) -- Draw panel here for _, child in pairs(self.children) do child:draw() end clip.pop() end [/lua] I don't know what I'm supposed to be explaining to you at this point, all the tools for doing what you want are by your fingertips.
  • [QUOTE=Map in a box;34785865]The children need to be clipped to the parents, too.[/QUOTE] Here's the solution I used for my LÖVE GUI library: [lua] function Panel:render(ax, ay, aw, ah) local X, Y = self.X, self.Y local nax, nay = ax+X, ay+Y --print(self, aw-X, self.W) local naw, nah = math.min(aw-X, self.W), math.min(ah-Y, self.H) if naw > 0 and nah > 0 then love.graphics.push() love.graphics.translate(X, Y) love.graphics.setScissor(nax, nay, naw, nah) self:draw() local children = self.Children for child_i = 1, #children do children[child_i]:render(nax, nay, naw, nah) end love.graphics.pop() end love.graphics.setScissor() end [/lua]
  • Programming courses are cool and all but the write ups are fucking annoying. [img]http://i.imgur.com/zKjMj.png[/img]
  • [QUOTE=Dr Magnusson;34785937]Then push the panel's clipping region as you traverse down the chain of panels as you draw them. [lua] function Panel:draw() clip.push(self.x, self.y, self.w, self.h) g.setClipRegion(clip.getRegion()) -- Draw panel here for _, child in pairs(self.children) do child:draw() end clip.pop() end [/lua] I don't know what I'm supposed to be explaining to you at this point, all the tools for doing what you want are by your fingertips.[/QUOTE] Slick2D doesn't support stacked clips, which was my main problem to begin with. I'll just make a bug report. [editline]20th February 2012[/editline] What I'm working on: A web browser. :downs:
  • [QUOTE=Map in a box;34786473]Slick2D doesn't support stacked clips, which was my main problem to begin with. I'll just make a bug report. [editline]20th February 2012[/editline] What I'm working on: A web browser. :downs:[/QUOTE] There's only one thing you need support for, and that's clipping before you actually render. Does Slick2D do that? In other words, in your tests, is only one clip applying, and that clip being the last clip you perform? If not, then Slick2D provides everything you need.. except a brain, of course.
  • [QUOTE=Map in a box;34786473]Slick2D doesn't support stacked clips, which was my main problem to begin with. I'll just make a bug report.[/QUOTE] It's going to get ignored. You have everything you need already, and I've given you the answer. If you want to find the region where rectangles overlap, you find the minimum of the maximum bounds and the maximum of the minimum bounds. So as you're traversing the UI elements, you calculate and apply the new clip region as described. If you use recursion, you don't even need to write any fancy data structures, classes or subroutines to keep track of the clip regions, since each stack frame will have the correct clip region for that UI element.
  • [QUOTE=Paulendy;34786229]Programming courses are cool and all but the write ups are fucking annoying. -snip img-[/QUOTE] Your telling me! I have to make a table of every variable in my code and every fucking function it's used in with a page referance to that code page. What the fuck is the use of that?
  • Yes, unfortunately. I need to clip all the children and the subchildren, like what I do when I translate them. [editline]20th February 2012[/editline] [QUOTE=ROBO_DONUT;34786740]It's going to get ignored. You have everything you need already, and I've given you the answer. If you want to find the region where rectangles overlap, you find the minimum of the maximum bounds and the maximum of the minimum bounds. So as you're traversing the UI elements, you calculate and apply the new clip region as described. If you use recursion, you don't even need to write any fancy data structures, classes or subroutines to keep track of the clip regions, since each stack frame will have the correct clip region for that UI element.[/QUOTE] Look, with your method a subpanel could clip outside of its root panel. That is why I'm saying it won't work.
  • [QUOTE=amcfaggot;34777542]uh, alien swarm already has vscript[/QUOTE] Indeed it does, however vscript is closed source, by implementing it myself I have greater access.
  • [QUOTE=Map in a box;34786773] Look, with your method a subpanel could clip outside of its root panel. That is why I'm saying it won't work.[/QUOTE] [b]dude[/b] [i]no, it can't[/i] you find the intersection of your stack of clip rectangles, and you set that as the final clip rectangle [editline]20th February 2012[/editline] [img]http://i.imgur.com/3tIg2.png[/img]
  • [QUOTE=Map in a box;34786773]Look, with your method a subpanel could clip outside of its root panel.[/QUOTE] No, it can't. That doesn't even make sense. What you want is the intersection of the set of pixels, applied recursively as you traverse the UI tree. So, we start with a full-screen rectangle denoted 'A'. For the first (root) UI element, confined to rectangle 'B', the drawable region is 'A&#8745;B'. Then for the first child, in rectangle 'C', the drawable region would be '(A&#8745;B)&#8745;C'. That is, we take the previous calculated result ('A&#8745;B'), and intersect that with the clip region for the current UI element, 'C', resulting in 'A&#8745;B&#8745;C'. Every clip region for every parent, child, and sub-child all the way up and down the chain is accounted for. All you need is the formula for the intersection of rectangles, which I've given to you. It's: [code] x_min = max(x_min, current.x_min); x_max = min(x_max, current.x_max); y_min = max(y_min, current.y_min); y_max = min(y_max, current.y_max); if (x_min > x_max || y_min > y_max) { // no visible pixels return; } [/code] Apply recursively.
  • Finally wrote a hello world. In Java. For Android. It's actually not terrible. But when I write Java something about everything kind of irks me
  • [IMG]http://new.tinygrab.com/7cfbd517830a2c3188ded0ec403caad0e675e50f95.png[/IMG] Game == setup :v: