These are chat archives for highfidelity/hifi

17th
Apr 2017
Neet Bhagat
@NeetBhagat
Apr 17 2017 16:58
Hi, does anyone knows why objectTargetPosition sent from JS to CPP doesn't work as expected? Means if JS sent position = 52 -> 48 , CPP just move object to 52 -> 51.40
Any idea on it? How engine is working for objectMovement ?
Anthony Thibault
@hyperlogic
Apr 17 2017 17:15
@volansystech can you be more specific, I'm not sure what API you're using for "objectTargetPostion" are you talking about Entities.editEntity(entityID, { position: {x: 0, y: 0, z: 0} }); ?
Neet Bhagat
@NeetBhagat
Apr 17 2017 17:22
Hi @hyperlogic I am talking about "Entities.updateAction" written in handControllerGrab.js
Which redirect in EntityItem::updateAction() in EntityItem.cpp
Neet Bhagat
@NeetBhagat
Apr 17 2017 17:55
any idea? apart from this any idea on how object is moving in world ?
Anthony Thibault
@hyperlogic
Apr 17 2017 18:00
Hmm, not my area of expertise, maybe @sethalves or @AndrewMeadows can help.
Neet Bhagat
@NeetBhagat
Apr 17 2017 18:01
ok, @hyperlogic Thanks Man :)
Seth Alves
@sethalves
Apr 17 2017 18:03
@volansystech the targets of all the spring-like actions on a given entity are averaged. could that be what's throwing the result off?
Neet Bhagat
@NeetBhagat
Apr 17 2017 18:05
Yes, it looks like that
we traced values till objectActionSpring.cpp values were same as JS sent
but after that in world object does not reflects same movement
its always lesser than what JS sent
Seth Alves
@sethalves
Apr 17 2017 18:06
if you run actionInspector.js do you see more than one spring-like action on the entity?
(there's a bug that this script triggers that's going to cause crashes sometimes, so don't leave it up all the time)
Neet Bhagat
@NeetBhagat
Apr 17 2017 18:18
@sethalves Nope, we don't see more than one action
Seth Alves
@sethalves
Apr 17 2017 18:24
how are you testing to see where the entity actually ends up?
Neet Bhagat
@NeetBhagat
Apr 17 2017 18:24
From Debug Logs
Seth Alves
@sethalves
Apr 17 2017 18:24
put another way: how do you know it isn't moving to the endpoint of the sprint action?
Neet Bhagat
@NeetBhagat
Apr 17 2017 18:25
we just logged all values and came to know that objectTargetPosition set to 48 and in very next loop when we fetch objectCurrentPosition its around 51 which should be 48
Seth Alves
@sethalves
Apr 17 2017 18:27
oh, interesting. do you have more than one interface logged into the domain?
Neet Bhagat
@NeetBhagat
Apr 17 2017 18:29
ummm... not sure. Would you please elaborate, couldn't get it all.
Seth Alves
@sethalves
Apr 17 2017 18:29
which action are you using? is it "spring" or one of the others?
Neet Bhagat
@NeetBhagat
Apr 17 2017 18:30
spring
Seth Alves
@sethalves
Apr 17 2017 18:31
and what's the line of code you use to retrieve the position?
are you asking the spring for its "targetPosition" or are you asking the Entity for its position?
Neet Bhagat
@NeetBhagat
Apr 17 2017 18:33
object position: this.currentObjectPosition = grabbedProperties.position;
And we use Entities.updateAction with parameter targetPosition: newTargetPosition
In handControllerGrab.js
Seth Alves
@sethalves
Apr 17 2017 18:38
you may be using a cached value there. what if you print out Entities.getEntityProperties(this.grabbedThingID, ["position"]).position ?
Neet Bhagat
@NeetBhagat
Apr 17 2017 18:41
we are getting same value for both
1) var grabbedProperties = Entities.getEntityProperties(this.grabbedThingID, GRABBABLE_PROPERTIES);
2) this.currentObjectPosition

Logs:

[3/17 22:4:1] [defaultScripts.js] distanceHoldingEnter::grabbedProperties.position:::::::63.78725814819336::0.22133508324623108::-115.9197006225586
[3/17 22:4:1] [defaultScripts.js] distanceHoldingEnter::this.currentObjectPosition:::::::63.780372619628906::0.1258215606212616::-115.8321304321289

[3/17 22:4:1] [defaultScripts.js] distanceHoldingEnter::grabbedProperties.position:::::::63.78723907470703::0.22132651507854462::-115.9197006225586
[3/17 22:4:1] [defaultScripts.js] distanceHoldingEnter::this.currentObjectPosition:::::::63.78514862060547::0.021763280034065247::-115.77507019042969

3/17 22:4:1] [defaultScripts.js] distanceHoldingEnter::grabbedProperties.position:::::::63.80052185058594::0.22668005526065826::-115.97892761230469
[3/17 22:4:1] [defaultScripts.js] distanceHoldingEnter::this.currentObjectPosition:::::::63.77647018432617::-0.09112896770238876::-115.70822143554688

[3/17 22:4:1] [defaultScripts.js] distanceHoldingEnter::grabbedProperties.position:::::::63.813209533691406::0.23202571272850037::-116.03641510009766
[3/17 22:4:1] [defaultScripts.js] distanceHoldingEnter::this.currentObjectPosition:::::::63.7724609375::-0.16888287663459778::-115.61825561523438

Seth Alves
@sethalves
Apr 17 2017 18:44
could you add a print for what you're setting the action's target position to in there?
why is distanceHoldingEnter being called repeatedly?
I would expect distanceHoldingEnter once and distanceHolding to repeat
Neet Bhagat
@NeetBhagat
Apr 17 2017 18:45
its typo from me
Seth Alves
@sethalves
Apr 17 2017 18:45
ah
Neet Bhagat
@NeetBhagat
Apr 17 2017 18:45
I added that string
yes you are right
distanceHolding is repeating
Seth Alves
@sethalves
Apr 17 2017 18:46
okay. could you print when you update the action (or if you already do, find that line in your log)?
Neet Bhagat
@NeetBhagat
Apr 17 2017 18:47
let me pull out, wait for a minute
Neet Bhagat
@NeetBhagat
Apr 17 2017 18:56
[3/18 0:23:15] [defaultScripts.js] ---------------------
[3/18 0:23:15] [defaultScripts.js] this.currentObjectPosition::57.80696487426758::y::-0.06331674754619598::z::-99.21489715576172
[3/18 0:23:15] [defaultScripts.js] grabbedProperties.position::58.07788848876953::y::0.2189898043870926::z::-98.80280303955078
[3/18 0:23:15] [defaultScripts.js] newTargetPosition::58.080509185791016::y::0.20905612409114838::z::-99.17817687988281
[3/18 0:23:15] [defaultScripts.js] ---------------------
[3/18 0:23:15] [defaultScripts.js] this.currentObjectPosition::57.46016311645508::y::-0.38364177942276::z::-99.77301788330078
[3/18 0:23:15] [defaultScripts.js] grabbedProperties.position::58.07784652709961::y::0.21850033104419708::z::-98.80461120605469
[3/18 0:23:15] [defaultScripts.js] newTargetPosition::58.1043701171875::y::0.1671268790960312::z::-99.69086456298828
[3/18 0:23:15] [defaultScripts.js] ---------------------
[3/18 0:23:15] [defaultScripts.js] this.currentObjectPosition::57.17437744140625::y::-0.6271131038665771::z::-100.4749526977539
[3/18 0:23:15] [defaultScripts.js] grabbedProperties.position::58.078060150146484::y::0.2183002382516861::z::-98.81401062011719
[3/18 0:23:15] [defaultScripts.js] newTargetPosition::58.28091812133789::y::0.23279158771038055::z::-100.32418060302734
[3/18 0:23:15] [defaultScripts.js] ---------------------
[3/18 0:23:15] [defaultScripts.js] this.currentObjectPosition::56.904537200927734::y::-0.9173647165298462::z::-101.41702270507812
[3/18 0:23:15] [defaultScripts.js] grabbedProperties.position::58.08103942871094::y::0.2182619720697403::z::-98.8426742553711
[3/18 0:23:15] [defaultScripts.js] newTargetPosition::58.509552001953125::y::0.361377477645874::z::-101.1666030883789
[3/18 0:23:15] [defaultScripts.js] ---------------------
using this code
var success = Entities.updateAction(this.grabbedThingID, this.actionID, {
        targetPosition: newTargetPosition,
        linearTimeScale: this.distanceGrabTimescale(this.mass, distanceToObject),
        targetRotation: this.currentObjectRotation,
        angularTimeScale: this.distanceGrabTimescale(this.mass, distanceToObject),
        ttl: ACTION_TTL
    });
Seth Alves
@sethalves
Apr 17 2017 19:48
does it act the same if you don't set the timeScales?
I'll admit, I don't yet really understand what the problem is
Neet Bhagat
@NeetBhagat
Apr 17 2017 19:51
Let me try to explain,
BTW, this is public chat, shouldn't we move to private chat room?
so everybody don't get discturbed
Seth Alves
@sethalves
Apr 17 2017 19:53
anyone in this channel deserves what they get
i mean... if you'd prefer. heh
Neet Bhagat
@NeetBhagat
Apr 17 2017 19:54
ok, I'm new so I do not know our process
Just don't want to poke everyone for my queries, so I raised concern
Corey Evans
@whyroc
Apr 17 2017 20:11
I'm looking for a starting point for a game project within Hifi.. how can I persist player settings etc. like a standard MMO where health, status? High Fidelity obviously can handle the multiplayer aspects.. is there a preferred way to create a 'game manager' that could handle updating player stats, progress?
Seth Alves
@sethalves
Apr 17 2017 20:17
we don't (yet) provide a generic database. with current code, I would probably use the Messages interface to talk to a script that uses the xml http stuff to talk to my own database
you can store some stuff in Settings but that's only on the local computer
not even account-bound yet
you can store some information in the userData of entities, but that's also pretty limited
and it doesn't have any sort of transaction support
by xml http stuff I mean XMLHttpRequest
var req = new XMLHttpRequest(); req.responseType = 'json'; req.open("POST", "http://.../something.cgi", false); req.setRequestHeader("Content-Type", "application/json;charset=UTF-8"); req.send(JSON.stringify(inputs)); if (req.status == 200) { ... }
Corey Evans
@whyroc
Apr 17 2017 20:21
OK, so something like Firebase? ok got it, yes quite familiar with xml stuffs lol
cool thanks
Seth Alves
@sethalves
Apr 17 2017 20:22
yeah, but you probably don't want every client connecting directly, so I would set up a server-side script that listened for Messages
Corey Evans
@whyroc
Apr 17 2017 20:23
right makes sense
Corey Evans
@whyroc
Apr 17 2017 20:52
Any suggestions how to secure the auth credentials , keys etc?
Seth Alves
@sethalves
Apr 17 2017 20:56
I guess hard-code them into the script, and run the script with a file:// url? that's a good question
Corey Evans
@whyroc
Apr 17 2017 20:59
hmm, thinking about the same approach. Also wondering if OAuth would work