Monday, October 3, 2016

difference - 'Will be' vs 'will have been done' by [deadline]


I don't think there is any difference, either in choice of grammar or meaning, between, e.g.,



'Everything will be done by Tuesday.'
'Everything will have been done by Tuesday.'




except for the second one being more formal/grammatically rigorous. Is there?



Answer




'Everything will be done by Tuesday.'



This is a future simple tense, which means, 'everything' will be done in the future, with no indication whether you are doing it now(let's say it is sunday at the moment), at least it will be done by Tuesday.



'Everything will have been done by Tuesday.



Means, you are currently doing it now(from sunday to tuesday), clearly, this is future perfect tense. Will+have



Sunday, October 2, 2016

savegame - In which directory to write game save files/data?


I need a definite list of directories, one or more per platform, of where to put game save files and other game generated data. Either based on the OS developer specification, or because it is common usage if there is no recommendation.



Please provide one answer per platform, with different directories. Also, example of how to get the directory location in C++ or C is best, as it's the language you'll have more hard time.


Locations:



  • Player's game data (saved games, config).

  • Shared game data (like high-score or config for all computer users).

  • Temporary game data (aka cache directory).




The meaning of "around" in these sentences



What's working around communication? What's not?


What's working for you around influence? What's not?



Please tell me the meaning of these sentences. I have problem with the word ((around)) and so I can't understand the meaning of these sentences.


These questions were found in a leadership coaching blog:




Coaching Questions to Explore with Clients:



  1. What's working around communication? What's not?

  2. Thinking about your team, what are their preferences around communication? What are your preferences around communication?

  3. What are the strengths you bring to communication?

  4. What are your communication blindspots?

  5. What difficult conversations need to happen?


Coaching Questions to Explore with Clients:




  1. What does influence mean for you?

  2. What does influence look like?

  3. Where is influence most important to you in your role/team/department?

  4. What's working for you around influence? What's not?




Answer



This reads like the jargon common in self-help books, business schools, political workers, where you will see around in the sense of anything to do with.


Within their niche audiences, these kinds of sentences can have specific and useful meanings. Outside those audiences they can be very difficult, especially for learners.




  • I need help around self-esteem (Self-help: I want to improve how I think about myself)

  • We need to focus the problems around silo thinking (Business: Relationships between company departments is bad)

  • We need policy work around health services (Politics: What should our health service policy be?)


Saturday, October 1, 2016

opengl - Getting the number of fragments which passed the depth test



In "modern" environments, the "NV Occlusion Query" extension provides a method to get the number of fragments which passed the depth test. However, on the iPad / iPhone using OpenGL ES, the extension is not available.


What is the most performant approach to implement a similar behaviour in the fragment shader?


Some of my ideas:




  • Render the object completely in white, then count all the colors together using a two-pass shader where first a vertical line is rendered and for each fragment the shader computes the sum over the whole row. Then, a single vertex is rendered whose fragment sums all the partial sums of the first pass. Doesn't seem to be very efficient.




  • Render the object completely in white over a black background. Downsample recursively, abusing the hardware linear interpolation between textures until being at a reasonably small resolution. This leads to fragments which have a greyscale level depending on the number of white pixels where in their corresponding region. Is this even accurate enough?





  • Use mipmaps and simply read the pixel on the 1x1 level. Again the question of accuracy and if it is even possible using non-power-of-two textures.




The problem wit these approaches is, that the pipeline gets stalled which results in major performance issues. Therefore, I'm looking for a more performant way to accomplish my goal.


Using the EXT_OCCLUSION_QUERY_BOOLEAN extension


Apple introduced EXT_OCCLUSION_QUERY_BOOLEAN in iOS 5.0 for iPad 2.



"4.1.6  Occlusion Queries


Occlusion queries use query objects to track the number of fragments or
samples that pass the depth test. An occlusion query can be started and
finished by calling BeginQueryEXT and EndQueryEXT, respectively, with a
target of ANY_SAMPLES_PASSED_EXT or ANY_SAMPLES_PASSED_CONSERVATIVE_EXT.

When an occlusion query is started with the target
ANY_SAMPLES_PASSED_EXT, the samples-boolean state maintained by the GL is
set to FALSE. While that occlusion query is active, the samples-boolean
state is set to TRUE if any fragment or sample passes the depth test. When
the occlusion query finishes, the samples-boolean state of FALSE or TRUE is

written to the corresponding query object as the query result value, and
the query result for that object is marked as available. If the target of
the query is ANY_SAMPLES_PASSED_CONSERVATIVE_EXT, an implementation may
choose to use a less precise version of the test which can additionally set
the samples-boolean state to TRUE in some other implementation dependent
cases."

The first sentence hints on a behavior which is exactly what I'm looking for: getting the number of pixels which passed the depth test in an asynchronous manner without much performance loss. However, the rest of the document describes only how to get boolean results.


Is it possible to exploit this extension to get the pixel count? Does the hardware support it so that there may be hidden API to get access to the pixel count?


Other extensions which could be exploitable would be debugging features like the number of times the fragment shader was invoked (PSInvocations in DirectX - not sure if something simila is available in OpenGL ES). However, this would also result in a pipeline stall.





meaning in context - To sleep your way to the top




He was insinuating that she slept her way to the top.


Most memorably, Huffington urges the assembled luncheon group: “Sleep your way to the top. Four hours is not enough.” She is a big advocate of naps and of dreaming up ways to reshape the workplace that men have designed.



What does it mean?


As I see it, you either don't get to the top because you like to sleep a lot; or you get to the top through beds (fornicating).


EDIT:


I found this TED video where Arianna Huffington uses this idiom in a funny way.



Answer



It's intended as a form of wordplay. As the comments note, to sleep one's way to the top is an idiom that means the trading of sexual favours for advancement of some sort. Although it can be applied to both sexes, it is usually an insult leveled at women who, correctly or not, are perceived as being unqualified for the positions they hold. (The stereotypical unqualified secretary, for instance.)



Given this context, the phrase can be seen as empowering for women who nap to increase their productivity. Stated plainly, it would be something like this:



You know how they say you only got where you are because you slept your way there? Well, you know they're wrong in terms of sexual favours, but make it a literal reality. Sleep more. Be more productive with a nap. Turn the insult into personal betterment.



The context includes "workplaces men have designed", so it's fairly clear that Huffington intends for her listeners to pick up the double meaning. She's basically saying, "Take that insult, embrace it, and make it backfire."


In some ways, it can be seen as analogous to the old joke:



Three men walked into a bar. Two were fine, but one had to have stitches.



You expect one thing from the sentence, and then when the full context is given, there's a shift in your perceptions. Huffington is doing the same thing with the phrase "sleep your way to the top".



ios - Adding an angle variance to a 3d vector


I am converting a particle emitter from 2d to 3d.


In the 2d system the original coder used a random angle variance and added it to the angle. So it would be something like:


thisAngle = emitterAngle + angleVariance * RANDOM_MINUS_1_TO_1();


I want to do the same thing in 3d using an emission vector (vec3) and again an angleVariance. My specific variance for this particle will still be angleVariance * RANDOM_MINUS_1_TO_1(). But how do I apply that angle a 3d vector so that the new vector could be any value X degrees off of center. So if the original vector is straight up (0,1,0) the new vector could be off in the X or the Z and still normalized to 1.


Any hints? I have all the matrix and vector functions at my disposal.


=====


Thanks to nathan I was able to write this code. Not sure if I've over complicated it somewhere. Once I test it I'll checkmark his answer:


    // first pick a random Z from [cos(angleVariance), 1]
GLfloat varianceZ = [self randomFloatBetween:myCosf(angleVariance) andLargerFloat:1.0];
// and a random angle for the azimuth
GLfloat rndA = [self randomFloatBetween:0.0 andLargerFloat:360.0];

// then calculate the X & Y to make this a vector off of the +Z axis with a max width of angleVariance

GLfloat varianceX = sqrt(1 - varianceZ*varianceZ) * myCosf(rndA); // my functions input degrees not radians
GLfloat varianceY = sqrt(1 - varianceZ*varianceZ) * mySinf(rndA);

Up to here the above code works. It makes a variance angle off center but it is aligned to the +z axis. The next part is supposed to rotate/transform the angle to my emissionVector angle so it's a variance off of that. But so far this part isn't working.


    // next find an axis to rotate the point around to put it in line with the emmissionVector
vec3 rotationAxis = normalizeVec3(crossProduct(vec3Make(0.0, 0.0, 1.0), emissionVector));
GLfloat rotationAngle = acos(degreesToRadians(emissionVector.z));

// make a quaternion out of the rotation axis and angle
vec4 q = quaternionVector(rotationAxis, rotationAngle);

// turn the quaternion into a matrix
mat4 rotMat4;
mat3 rotMat3;
matrixQuaternion(q, rotMat4);
getMat3FromMat4(rotMat4, rotMat3);
// multiply the variance vector by the matrix to get a resulting vector with the variance added
vector = matrixTransformVec3(rotMat3, vec3Make(varianceX, varianceY, varianceZ));

=====


The above code doesn't appear to be correct. I'm still working on the solution and will fix the above code when I get it working.




Answer



There is a formula for picking a random point on a sphere which can be adapted for your purposes. Generating a random point on a sphere can be done by picking a z-coordinate uniformly at random in [–1, 1], then selecting a random angle θ in [0, 2π] and calculating:


x = sqrt(1 - z^2) * cos θ
y = sqrt(1 - z^2) * sin θ

This can be extended to pick a random point on a spherical cap with any angular width, by simply choosing z uniformly at random within [cos(angleVariance), 1] instead of [–1, 1]. Then apply the preceding formulas for x and y as usual, and you'll end up with a random point distributed around the +Z axis but staying within angleVariance of it.


Finally, you can rotate the resulting point to align the +Z axis with your desired emission vector. To do this, you can rotate around the axis normalize(cross(float3(0, 0, 1), emissionVector)) by the angle acos(emissionVector.z).


opengl - How to implement translation, scale, rotation gizmos for manipulating 3D object's transforms?


I am in the process of developing a basic 3D editor. It uses OpenGL for rendering a 3D world. Right now my scene is just a few boxes of different sizes and I am at the stage where I want to be able to select each box and then move/scale/rotate it to achieve any transform I want.


How can I solve the problem of implementing both the rendering of these tool's gizmos(or handles, or how people usually call them), and also picking them on each axis to perform the change in the transform with my mouse? For clarity: enter image description here


My research so far suggested the cleanest approach is to have an axis aligned bounding box per arrow in the gizmo and another one per square (the ones that move the object in a plane rather than a single axis) and then cast a ray from the mouse position and see what it collides with. But this is still a bit too abstract for me, I would appreciate further guidance in how this algorithm would go (pseudocode is more than enough)




Simple past, Present perfect Past perfect

Can you tell me which form of the following sentences is the correct one please? Imagine two friends discussing the gym... I was in a good s...