These are chat archives for highfidelity/hifi

10th
Jul 2014
AlericInglewood
@AlericInglewood
Jul 10 2014 13:41
I'm trying to declare a default vector in javascript of type Vec3. I'm trying this:
var center = new Vec3();
But that gives me:
Uncaught exception at ( "/opt/highfidelity/hifi/scripts/lookWithMouse.js" ) line 90 : "TypeError: Result of expression 'Vec3' [Vec3(name = "")] is not a constructor."
What am doing wrong? What I really need is that it has the value 0,0,0
Andrew Meadows
@AndrewMeadows
Jul 10 2014 16:27
Aleric. I think the way to do what you want is like this: var center = {x:0, y:0, z:0};
Vec3 is a global object that has some methods that can operate on "3D vector" instances. A "3D vector" instance is really just a map with x,y,z keys that all have float values. It is a JavaScript-ism.
AlericInglewood
@AlericInglewood
Jul 10 2014 16:58
@ZappoMan I saw you review comment "coding standard: Add brackets even for 1 line control structures", but I'm not sure where you are referring to :/. Can you give me a line number of paste the code line here please?
AlericInglewood
@AlericInglewood
Jul 10 2014 17:10

@ZappoMan I'm going to assume that you mean these three lines:

+                if (event->type() == QEvent::KeyPress)
+                    keyPressEvent(keyEvent);
+                else if (event->type() == QEvent::KeyRelease)
+                    keyReleaseEvent(keyEvent);
+                else
+                    QGLWidget::event(event);

And that that is all ;). Thanks

This message was deleted
This message was deleted
Brad Hefta-Gaub
@ZappoMan
Jul 10 2014 17:15
@AlericInglewood - I am certainly refering to those lines, but also any and all other cases where you have an if statement.
@AlericInglewood - I left the comment in gitHub in a manner that should show it next to the line I was referring to. In this case, I left it on the first if statement.
AlericInglewood
@AlericInglewood
Jul 10 2014 17:17

@ZappoMan Sure - I understand :). I don't have more lines like that in this patch though. I thought maybe you wanted also:

default: {
    break;
}

:)

Brad Hefta-Gaub
@ZappoMan
Jul 10 2014 17:18
@AlericInglewood - the coding standard is current ambiguous on the placement of braces in switch statements. I just sent a mail to the rest of the core dev team this morning asking about considering cleaning up and codifying this issue
your switch/case statement is fine for now. But the standard may change, in which case we'll end up going back and cleaning up the old code as we touch it.
AlericInglewood
@AlericInglewood
Jul 10 2014 17:19
Also... I put the '{' below the case line. Hope that is ok. I always put { and } in the same column - that has benefits for seeing matching braces as well as indenting/unindenting in vim... It looks bad in my eyes with the '{' place that hifi uses. :(
Ah, you just addressed that. k.
Brad Hefta-Gaub
@ZappoMan
Jul 10 2014 17:20
@AlericInglewood - the key to any coding standard is consistency… please follow the standard.
we will only merge code that matches the standard.
Thijs Wenker
@thoys
Jul 10 2014 17:22
@ZappoMan is there also some kind of automated tool that can check c++ code standard? would be nice if we can pre-check it :P
Brad Hefta-Gaub
@ZappoMan
Jul 10 2014 17:23
@thoys - I am personally not familiar with tools for that sort of thing. I'm sure someone has developed one. We are not using one at this point. I find it pretty easy to review once you're familiar with the standard.
AlericInglewood
@AlericInglewood
Jul 10 2014 17:24
@ZappoMan There also isn't a style rule for 'const TYPE*' versus 'TYPE const*'. I strongly prefer the latter for logical reasons... I used to have a webpage about that on my home page, but I took my home page down a month ago :\
Brad Hefta-Gaub
@ZappoMan
Jul 10 2014 17:25
Here's another rule of thumb that I've found has worked in my career of 20+ years writing code…
when you first show up in a new code base… LOOK AROUND… what do you see?
in general… you should treat code, like the forrest… leave no trace of your presence...
so if the code appears to generally follow a particular style, you should be able to glean that style from what you observe
And, to be a good citizen in the code, you should try to match that style...
As for the question of "const TYPE" vs "TYPE const" let me ask you @AlericInglewood - what have you observed in the code so far?
AlericInglewood
@AlericInglewood
Jul 10 2014 17:28
@ZappoMan Only 20 years? :P
Brad Hefta-Gaub
@ZappoMan
Jul 10 2014 17:28
I am an old soul in a young man's body.
AlericInglewood
@AlericInglewood
Jul 10 2014 17:29
I meant, that's less than me :P heheh
Brad Hefta-Gaub
@ZappoMan
Jul 10 2014 17:30
the + operator… not the ++ operator...
to answer your question… use const TYPE* variableName
that's the standard - even if it's not explicit. the entire core team agrees on this one, so we'll fix the standard.
Thijs Wenker
@thoys
Jul 10 2014 17:32
btw @ZappoMan i figured you can use const in the javascript aswell
AlericInglewood
@AlericInglewood
Jul 10 2014 17:33
I coded for decades using const TYPE&, but once I switched to TYPE const& it only took me two weeks to be CONVINCED that that was much better and couldn't understand I'd ever had used the previous style. The fact that I got used to the new style so quickly after using the other style for that long should be prove of how much better / more logical it is. Of course I noticed that the current code is using 'const TYPE&' but you don't have a good reason for that, it's just what Philip (I guess) was using, for historical reasons, when he started to hack the first code. As you just mentioned with regard to switch and { }: the coding style can still be changed. If that is the case that I'd urge you to switch to 'TYPE const&', if only because it looks a hell of a lot more professional for C++ coders :P (while the other style what C coders use.. going back to K&R)...
Brad Hefta-Gaub
@ZappoMan
Jul 10 2014 17:34
thanks for your feedback
@thoys - it looks like const is non-standard in ECMAScript… I haven't tested to see if it works in the Qt script engine.
Thijs Wenker
@thoys
Jul 10 2014 17:38
It works in the QT script engine, do you think I should add it to the highlighting?
AlericInglewood
@AlericInglewood
Jul 10 2014 17:41
The reason that 'TYPE const' is better is because it works for any 'TYPE'; ie, for a literal 'int', but also for 'int*', or 'int const*'. While 'const TYPE' changes meaning when you change TYPE from a non-pointer or reference type to a pointer or reference. In general, type qualifiers always work right-to-left; for example if TYPE = 'int** const*' (or whatever), then 'TYPE*' means "pointer to TYPE". And 'TYPE const' means: a read-only TYPE. Being able to put 'const' on the LEFT (and have it work from left-to-right) is an exception and only works for non-pointers and -references. I'm convinced that anyone who'd try the 'TYPE const&' style would get used it very fast and be happy with it; while the other way around is definitely not the case.
Thijs Wenker
@thoys
Jul 10 2014 17:45
@ZappoMan hmm const is usable in QT JS, but it seems to be not working like a constant, I can just simply reassign a value to it
AlericInglewood
@AlericInglewood
Jul 10 2014 18:00
Is it normal that my mouse pointer is not visible when I hover over the GLCanvas? It's very annoying not being able to see where your mouse is when you want to click on something :\ .
AlericInglewood
@AlericInglewood
Jul 10 2014 18:19
@thoys @cozza13 Is has to do with audio, I get this every 4 seconds:
[...more than 40 lines that are the same now...]
[2014-07-10T20:18:08] Packet of type 8 received from unknown node with UUID QUuid("{55f01146-f05d-4b3a-a4cb-643517cf95be}") 
[2014-07-10T20:18:08] Packet of type 8 received from unknown node with UUID QUuid("{55f01146-f05d-4b3a-a4cb-643517cf95be}") 
[2014-07-10T20:18:08] Added "Audio Mixer" (M) {55f01146-f05d-4b3a-a4cb-643517cf95be} 54.241.217.33:52467 / 10.166.213.22:52467 
[2014-07-10T20:18:08] Activating public socket for node "Audio Mixer" (M) {55f01146-f05d-4b3a-a4cb-643517cf95be} 54.241.217.33:52467 / 10.166.213.22:52467 
[2014-07-10T20:18:12] Killed "Audio Mixer" (M) {55f01146-f05d-4b3a-a4cb-643517cf95be} 54.241.217.33:52467 / 10.166.213.22:52467
AlericInglewood
@AlericInglewood
Jul 10 2014 19:05
All Shape objects of my avatar with type SPHERE_SHAPE have _boundingRadius = 0, _translation = {{x = 0, r = 0, s = 0}, {
y = 0, g = 0, t = 0}, {z = 0, b = 0, p = 0}}, _rotation = {x = 0, y = 0, z = 0, w = 1}
Is Avatar::findRayIntersection working at all? I can't get it to intersect my avatar.
Andrew Meadows
@AndrewMeadows
Jul 10 2014 19:39
I don't think we support ray intersection with the Shapes yet. That is something that needs to be added.
AlericInglewood
@AlericInglewood
Jul 10 2014 19:40
@AndrewMeadows I'm adding it :P
Andrew Meadows
@AndrewMeadows
Jul 10 2014 19:40
however... I think the implementation of Avatar::findRayIntersection() uses some older code that uses some "conical capsules" that are created on the fly
so it might still work in theory... I'll look.
AlericInglewood
@AlericInglewood
Jul 10 2014 19:41
That is, I'm adding it for javascripts.. but I was assuming that the existing bool Avatar::findRayIntersection would actually work - and not be totally broken. I'd like to know if that needs to repaired too :(
So far it seems that it is not working. It always returns false (even when it should intersect)
Andrew Meadows
@AndrewMeadows
Jul 10 2014 19:43
hrm... I take that back. It appears that there are some ray-vs-shape code. And I wrote it. It's all a blur.
AlericInglewood
@AlericInglewood
Jul 10 2014 19:44
The ray intersection for Avatar calls a function on SkeletonModel which runs over a list of Shape objects - 70 Shapes for my avatar... You'd think that they should work when there are 70 of them! heheh.
However, seeing that all spherical shapes have a radius of 0 .. something is wrong :P. I wish there was an easy way to make them visible in world.
Andrew Meadows
@AndrewMeadows
Jul 10 2014 19:46
Hrm...
SkeletonModel derives from Model, which derives from PhysicalEntity, which is where the findRayIntersection() method comes from.
I suspect the shapes are currently in the model-frame, which is why the ray-trace is not working.
that is your ray is probably in the world-frame. You may be able to test this theory by putting your avatar at the origin (looking along Z I think) and tracing against it there.
AlericInglewood @AlericInglewood ponders getting Shyotl (another Singularity viewer developer) interested for hifi. He's by far the best openGL wizard that I know. Only problem is that if he comes here too then Singularity is dead (it basically is already now.. but Shyotl is capable of miracles.. I bet he can maintain it all on his own).
AlericInglewood
@AlericInglewood
Jul 10 2014 19:49
Just saying cause it would take him one hour I bet to implement showing shapes in world :*)
Andrew Meadows
@AndrewMeadows
Jul 10 2014 19:50
There is a way to visualize the shapes of the skeleton... Developer ==> Avatar Options ==> Skeleton Collision Shapes
but at the moment the shapes are only created for MyAvatar, not others.
The avatar should not be all sphere shapes. The SphereShape is a fallback for joints for which we fail to compute valid capsules
In any case, the collision shapes for the avatar are not very good at the moment. They are approximations.
I'm currently working on some self-collisions between skeleton joints. I'll get that working before I start building shapes for other avatars.
AlericInglewood
@AlericInglewood
Jul 10 2014 19:54
@AndrewMeadows It would help me a lot at the moment if I could see my mouse pointer! Is there a setting too that causes it to be hidden as soon as I hover the GLCanvas? I'm not even sure if I manage to click my avatar (or a shape) now :\
Thijs Wenker
@thoys
Jul 10 2014 19:55
@AlericInglewood did you ever see the mousepointer on the GLCanvas?
Marios Antonoudiou
@mariosant
Jul 10 2014 19:55
/add bug test for worklist KABOOM
BUG #18071 for project hifi - test for worklist KABOOM has been successfully created. http://dev.worklist.net/~qboss/worklist/18071
Thijs Wenker
@thoys
Jul 10 2014 19:55
haha
Marios Antonoudiou
@mariosant
Jul 10 2014 19:55
enjoy :)
Thijs Wenker
@thoys
Jul 10 2014 19:56
thanks Marios
AlericInglewood
@AlericInglewood
Jul 10 2014 19:57
@thoys Unfortunately, I am not sure. :/. I suppose I could go back to a much older commit to check.
Thijs Wenker
@thoys
Jul 10 2014 19:57
It could be another Linux qt bug
AlericInglewood
@AlericInglewood
Jul 10 2014 19:58
You're saying that you see the mouse fine on OSX and PC? That's always nice to know: then I know that it is a bug at all :P
Andrew Meadows
@AndrewMeadows
Jul 10 2014 19:58
I can see my mousepointer on the GLCanvas (Kubuntu 16)
Thijs Wenker
@thoys
Jul 10 2014 19:59
but thats a Kool Ubuntu
AlericInglewood
@AlericInglewood
Jul 10 2014 19:59
If it should be visible, then I know enough.. then I'll dig into it.
Thijs Wenker
@thoys
Jul 10 2014 19:59
Yeh, try to delete your settings file
AlericInglewood
@AlericInglewood
Jul 10 2014 19:59
This message was deleted
Thijs Wenker
@thoys
Jul 10 2014 20:00
Not sure in what folder it is on your OS but its named Interface.ini
AlericInglewood
@AlericInglewood
Jul 10 2014 20:00
I got it
AlericInglewood
@AlericInglewood
Jul 10 2014 20:08
Can't see my mouse after deleting interface.ini either... And I ran into a new crash:
[2014-07-10T22:07:08] ASSERT failure in QCoreApplication::sendEvent: "Cannot send events to objects owned by a different thread. Current thread aa589c0. Receiver '' (of type 'QMenu') was created in thread 198a550", file kernel/qcoreapplication.cpp, line 505
Aborted
Thijs Wenker
@thoys
Jul 10 2014 20:17
@AlericInglewood Maybe you can try the /add bug feature that @qboss just showed us to report this
Marios Antonoudiou
@mariosant
Jul 10 2014 20:17
BUG #undefined for project hifi - feature that @qboss just showed us to report this has been successfully created. http://dev.worklist.net/~qboss/worklist/undefined
Thijs Wenker
@thoys
Jul 10 2014 20:17
oh lol
Marios Antonoudiou
@mariosant
Jul 10 2014 20:18
:D
I need to fix that hahaha
Thijs Wenker
@thoys
Jul 10 2014 20:18
hahaha
Marios Antonoudiou
@mariosant
Jul 10 2014 20:18
anyway, don't be shy it's running on my dev sandbox
does not touch real worklist yet
Thijs Wenker
@thoys
Jul 10 2014 20:19
ah so the reports will go straight to the bin?
:P
AlericInglewood
@AlericInglewood
Jul 10 2014 20:20
/add something instead of bug
/add bugger I made a typo
/add bug does it work at all?
Marios Antonoudiou
@mariosant
Jul 10 2014 20:21
BUG #undefined for project hifi - does it work at all? has been successfully created. http://dev.worklist.net/~qboss/worklist/undefined
AlericInglewood
@AlericInglewood
Jul 10 2014 20:22
Personally I'd use /addbug, not something with a space in between :P
/add bug An /add bug test with a typo in the comment <-- editted
Marios Antonoudiou
@mariosant
Jul 10 2014 20:23
BUG #undefined for project hifi - An /add bug test with a typo in the cmmoent. has been successfully created. http://dev.worklist.net/~qboss/worklist/undefined
BUG #18073 for project hifi - test with a typo in the cmmoent. has been successfully created. http://dev.worklist.net/~qboss/worklist/undefined has been successfully created. http://dev.worklist.net/~qboss/worklist/18073
Thijs Wenker
@thoys
Jul 10 2014 20:23
hm
you've just added a bug in a bug report
Lucas Crisman
@kordero
Jul 10 2014 20:24
lol
I guess something is wrong there
Thijs Wenker
@thoys
Jul 10 2014 20:25
ohh he added the bug himself, thats how it did get a number the second time
AlericInglewood
@AlericInglewood
Jul 10 2014 20:25
It saw two times /add .. and added them both.
@thoys Actually - I have a mouse pointer now. Deleting the settings file did help. Still a bug imho :P....
AlericInglewood
@AlericInglewood
Jul 10 2014 21:16
k.. I found out why my mouse disappeared. It's cause I call "Controller.captureMouseEvents()" in a script, which disable ALL mouse handling by the application, including making it visible again when you move the mouse. That seems a bug to me, no?
If that is not a bug then at the very least the script should be able to make the mouse visible and invisible itself. Probably that would be best (along with being able to reposition it).
Andrew Meadows
@AndrewMeadows
Jul 10 2014 21:21
I think there is a way to allow the script to capture mouse events but also to allow them to pass through to the application.
perhaps that is what you want to do?
AlericInglewood
@AlericInglewood
Jul 10 2014 21:22
I'm just looking at void Application::mouseMoveEvent(QMouseEvent* event) {
That totally kills making the mouse visible after capturing the mouse = no way passing the event back to the application to make it happen, unless there is code duplication somewhere :P
Andrew Meadows
@AndrewMeadows
Jul 10 2014 21:25
ok. I'm not an expert on that code. I thought I remembered hearing someone talk about it.
AlericInglewood
@AlericInglewood
Jul 10 2014 21:25
I checked it - code duplication is not there. There is no way to make the mouse visible from a script except calling Controller.releaseMouseEvents()
So there are imho two options: either calling Controller.captureMouseEvents() should not disable the hiding and making visible of the mouse (that is: show it when it is moved, and hide it when it hasn't moved for a second or so), or the script needs to get a new call to do show and hide the mouse itself.
The latter seem preferable, as it is the most flexible and powerful... Although for the lazy scripters you might want to have an option that does the first case anyway.
Andrew Meadows
@AndrewMeadows
Jul 10 2014 21:42
I agree. Flexibility and convenience -- there is a balance to be struck.