Jump to content

  • Log In with Google      Sign In   
  • Create Account

FREE SOFTWARE GIVEAWAY

We have 4 x Pro Licences (valued at $59 each) for 2d modular animation software Spriter to give away in this Thursday's GDNet Direct email newsletter.


Read more in this forum topic or make sure you're signed up (from the right-hand sidebar on the homepage) and read Thursday's newsletter to get in the running!


fastcall22

Member Since 04 Feb 2008
Offline Last Active Today, 12:48 AM

#5199652 Boost c++ How to Deserialize Element of Container

Posted by fastcall22 on 23 December 2014 - 01:56 AM

Use an index table.

1. Reserve some space at the beginning of the file for the index table.
2. Serialize each entity, noting the write position of the stream, and store that and the entity ID into the table.
3. After serializing the entities, sort the table by entity ID.
4. Write the number of entities and the contents of the table to the beginning of the file.

When looking for a specific set of entities, all you'll need to do is to read the entire index, binary search for the entity IDs you're looking for, set the read position of the stream, then deserialize the entity. smile.png


#5199218 Chess moves

Posted by fastcall22 on 20 December 2014 - 12:43 AM

That is very disappointing. I guess I'll have to find some other programmer use for a 5TB external hard drive.

Oh, I know!! How about...

...

...
 
Spoiler



#5199041 C++ how to declare something that isn't declared?!?

Posted by fastcall22 on 18 December 2014 - 07:48 PM

Oberon:
It's not.

My guess is that WiredCat is trying to follow Borland convention or Pascal convention...


#5196679 Does ImageIO.read work in Java applets?

Posted by fastcall22 on 06 December 2014 - 02:20 PM

"Java applet"? What year is it??


#5195611 Crash with <unable to read memory> error

Posted by fastcall22 on 30 November 2014 - 09:09 PM

Check the object you're calling on; it could be null or invalid.


#5195610 *. not the same as ->

Posted by fastcall22 on 30 November 2014 - 09:04 PM

struct Foobar {
    int member;
};

int main() {
    Foobar f = {2};
    Foobar* ptr = &f;

    return (*ptr).member == ptr->member && ptr->member == f.member;
}
Hmm?


#5184826 Quaternion camera flipping constantly

Posted by fastcall22 on 03 October 2014 - 02:12 PM

I had a similar problem in the past. The problem was that I assumed quat::fromRotation(ang,x,y,z) == quat(ang,x,y,z), which isn't true. See Axis Angle to Quaternion.


#5184375 This chat, apparently, is a gigantic coding horror

Posted by fastcall22 on 01 October 2014 - 11:57 AM

Okay, dsm, I'm sorry for flying off the handle. I just got frustrated because you weren't understanding Unicode and/or HTML.
Anyways, it's not technically a blank line in much the same way " " isn't blank line. The difference is that the latter isn't allowed because it's recognized as just spaces, whereas the former is allowed, because it doesn't recgonize &​#x200B; as a non-printable character.


#5184370 This chat, apparently, is a gigantic coding horror

Posted by fastcall22 on 01 October 2014 - 11:42 AM

No, dsm, that's wrong. It's "&​#x200B;", which is a ZERO WIDTH SPACE, which I've been trying to explain to you this past half hour that it can be used to escape chars:

"__&​#x200B;A__" is displayed as "__A__", whereas
"__A__" is displayed as "&".


#5184232 This chat, apparently, is a gigantic coding horror

Posted by fastcall22 on 30 September 2014 - 11:43 PM

Okay. Now, just remember your order of operations from grade school:

PSycho Phil And Elvis Clean Noodles.
PS P A E C N
+ % & = , \n


#5184110 This chat, apparently, is a gigantic coding horror

Posted by fastcall22 on 30 September 2014 - 01:17 PM

So lots of little quirks about the chat.
Some people here discovered some time ago that typing the message "=A=" gives "__E&E__". Well, isn't that just the cutest little thing?

Today, I found out why.
I noticed when inspecting network requests to and from the chat, that "=" gets transformed into "__E__"
Hey, that's curious... looks a bit like an HTML entity would, doesn't it?

Sure enough, it seems a small handful of HTML entities are translated:
input output
__A__  &
__PS__ +
__C__  ,
__E__  =
So the original string, "=A=", expands to "__E__A__E__", but for some reason, "__A__" is replaced first, thus giving the strange "__E&E__". However, "__A__E__A__" is correctly contracted to "&E&".
This gives me the terrible feeling that someone somewhere is chaining string replace on the message like so:
 
message = message
    .replace("__PS__","+")
    .replace("__A__","&")
    .replace("__E__","=")
    .replace("__C__",",");
... which doesn't make sense, since both PHP and javascript have a callback for regular expression replace:
 
$replacements = [
    "__A__" => "&", # or html equivalent
    "__PS__" => "+",
    "__C__" => ",",
    "__E__" => "="
];

preg_replace($message,"/__[A-Z]{1,2}__/g",function ($match) use(&$replacements) {
    return @$replacements[$match] ?: $match;
});

Sooo... wtf, IPS.


#5181104 Multiples of 16B constant buffer or Microsoft gone mad.

Posted by fastcall22 on 17 September 2014 - 02:14 PM

http://thecodinglove.com/post/97565023437/when-i-use-a-new-library-without-reading-the

Also, alignment.


#5181068 sign(a)

Posted by fastcall22 on 17 September 2014 - 12:44 PM

x/abs(x)

x>0?1:-1;

EDIT:
Sprry, didn't see HLSL tag


#5180281 Algorithm for covering as much dots a as possible?

Posted by fastcall22 on 14 September 2014 - 11:45 AM

If I have a rectangle of random size and it has random dots in it.( = Rectangle A)

I want to take a rectangle that's inside A to cover as many dots as possible.


Then rectangle A will be a rectangle that's inside A and also covers as many dots as possible.
Are you thinking about bounding boxes? In that case, it's easy:
 
ptMin = vec2.uniform(float::max)
ptMax = vec2.uniform(float::min)

for pt in pts
  ptMin = min(ptMin, pt)
  ptMax = max(ptMax, pt)



#5179967 Static or dynamic object allocation?

Posted by fastcall22 on 12 September 2014 - 02:45 PM

Because the size of the object's data is not known at compile time or the lifetime of the objects aren't guaranteed to be FILO. There's nothing wrong with dynamically allocating memory. There is, however, problems with misusing dynamic memory, such as: Frequent allocation and deallocation of small objects (use object pooling), freeing objects that don't belong to your process's or DLL's private heap (such as attempting to free an object you obtained through a DLL boundary), and using it where stack based allocation is more appropriate.




PARTNERS