Unreal engine: How to get FHitResult.FaceIndex? - raycasting

When I do
PlayerController->GetHitResultUnderCursor(ECollisionChannel::ECC_WorldDynamic, false, TraceResult);
TraceResult.FaceIndex is always -1.
Here #OriCohen says that I have to "use a triangle mesh for the query". Do I have to use GetHitResultUnderCursorForObjects() with "triangle mesh" for the object type? Then how should I do it (EObjectTypeQuery is very obscure to me)?
Here is the question on UE4 answerhub.

To obtain a valid FaceIndex you need to make sure bReturnFaceIndex and bTraceComplex are set to true in your FCollisionQueryParams.

Related

Where is scripted the Dalaran Well teleport (game object)?

When you try to reach the Dalaran Well in Dalaran, you are teleported to the sewers.
It is using this Game object: Doodad_Dalaran_Well_01 (id = 193904 )
Where is it scripted? How?
I've found nothing in the table smart_scripts, and found nothing in the core about this specific id so I'm curious because this type of teleport is really better than clicking on a game object
This gameobject is a unique case because it works like instance teleports do. If you check the gameobject_template table, you will see that it has several Data columns that have diferent values based on the type of the gameobject.
The gameobject you are refering too is the Well It self but the portal gameobject inside the well gives the player a dummy spell to tell the core that the player has been teleported (spell ID 61652).
For the specific case of the dalaran well, it's type is 30 which means, as the documentation says, GAMEOBJECT_TYPE_AURAGENERATOR. As soon as the player is in range, a dummy aura is cast on him to notify the core that this areatrigger has been activated (You could do stuff when player gets hit by the dummy spell).
The trick here is a bunny, but not the bunny itself since it is there mostly to determine an areatrigger. If you use command .go gobject 61148 you can check him out, he's inside the well.
Areatriggers are a DBC object that are actually present on our database on world.areatrigger. You can check the columns here. When the player enters the Radius box specified on the areatrigger, another thing happens in the core which is world.areatrigger_teleport.
If you run the following query you will be able to check the position where the trigger will teleport the player to.
SELECT * FROM areatrigger_teleport WHERE `Name` LIKE '%Dalaran Well teleporter%';

validate.js returning error "unknown validator pattern"

I'm trying to use validate.js to validate input from the front end before entering it in the database with node but I'm getting an error that I can't figure out. I've gone over the docs and believe I setup the constraints correctly. The exact error is:
message:"Unknown validator pattern"
my validator is setup like this:
let alphanumeric = /^[a-zA-Z0-9]*$/;
let constraints = {
clientUsername:{
presence: true,
length: {min:8, max:15},
pattern:alphanumeric,
message: 'make sure client username is between 8-15 characters, is only numbers and letters'
},
tileCategory:{
presence:true,
length:{min:1, max:1},
numericality:{
onlyInteger:true,
lessThanOrEqualTo:tileCategoryNumber,
},
message:'enter a number, 1 char in length, less than or equal to 3' //the current number of tiles
}
};
validate({clientUsername: input.clientUsername},constraints);
At first I thought it was the regex pattern but tried commenting that out and then it said
message:"Unknown validator messsage"
so I'm guessing there is something wrong with my validator in general.
at the very top I of course included const validate = require('validate.js');
Something similar to this just burned me, have a look at the documentation again.
pattern is sort of a sub-validator of format and should look like:
{
format: {
pattern: "[A-Za-z0-9]+"
}
}
You're trying to use pattern at the "top level". I don't see anything in the documentation that implies helper patterns like alphanumeric exist. (I think the language the tool would use is to say "pattern is an option of the format validator" but I'm not sure.)
Your stated error message also implies a misspelling: it tells you it doesn't recognize messsage, which has 3 of the letter 's' but should have 2.
There's (2) things I could see being the issue. Firstly, you're using JS based regexes with the preceding and following /. Try removing these.
Beyond that, I'd recommend trying to remove the alphanumeric parameter & input the regex directly... it may be a type issue as well.
pattern:"^[a-zA-Z0-9]*$",
Hope this helps! :)

OpenLayers 3: "Unable to get property 'leaf' of undefined or null reference."

Using Open layers 3.7.0.
I have layer with features. I remove one, build a new similar one, add the new one and I get error message
"Unable to get property 'leaf' of undefined or null reference."
I have searched for what could cause that but search don't give any result.
Some more from the same error (I used v3.8.2 here but got exactly the same:
at rbush.prototype._chooseSubtree (http://openlayers.org/en/v3.8.2/build/ol-debug.js:70778:13)
at rbush.prototype._insert (http://openlayers.org/en/v3.8.2/build/ol-debug.js:70815:9)
at rbush.prototype.insert (http://openlayers.org/en/v3.8.2/build/ol-debug.js:70623:19)
at ol.structs.RBush.prototype.insert (http://openlayers.org/en/v3.8.2/build/ol-debug.js:71178:3)
at ol.source.Vector.prototype.addFeatureInternal (http://openlayers.org/en/v3.8.2/build/ol-debug.js:71589:7)
at ol.source.Vector.prototype.addFeature (http://openlayers.org/en/v3.8.2/build/ol-debug.js:71566:3)
Progress
Where we build the feature we have a projection.
var lineString = new ol.geom.LineString(coordinates);
lineString.transform("EPSG:4326", "EPSG:3857");
var feature = new ol.Feature(lineString);
(...)
If we comment/remove
//lineString.transform("EPSG:4326", "EPSG:3857");
Then there is no bug. By the way that's an hint, not a solution as the features are then not located where they should be.
Solution found
I do not think that this is a perfect soluton but I solved the problem regarding or application by saving the LineStrings in memory instead of re-creating it.
Then I still recreate the Feature from existing LineString.
I got the same error on console and I solved this testing if the features had a valid geometry(coordinates), so I discard the inclusion of the invalid features on the layer source.

When can we get access to nest autoaway status?

Let me stress that I am not a programmer but I like messing around with things. I've been using #ifttt and #nest for years and recently started using #smartthings to do cool things in my house.
I wanted to power off devices such as my lights and water heater based on leaving my house. Rather than having this depend on one device such as a phone or keyfoob, I wanted to use the nest "auto-away" feature.
Auto-away doesn't appear to be exposed to #ifttt or #smartthings. I've asked #nestsupport and they told me to come here :-o.
Does anyone from nest developer team know when developers and other products will be able to consume this from he nest device? Its a real shame that after several years this isn't exposed yet. Not only that but it could be an additional selling point to integrate and turn on/off items in your house.
Thank
I'm not from the Nest developer team, but I've played around with the Nest API in the past, and use it to plot my energy usage.
The 'auto away' information is already accessible in the API, and looks to be used in a number of IFTTT recipes:
https://ifttt.com/recipes/search?q=auto+away&ac=false
Within the (JSON) data received back in the API, the 'auto away' status is accessible via;
shared->{serial_number}->auto_away
This is set as a boolean (0 or 1).
If you like messing around with code, and know any PHP, then this PHP class for the Nest API is very useful at grabbing all information etc;
https://github.com/gboudreau/nest-api
Auto-Away is and always has been readable https://developer.nest.com/documentation/cloud/api-overview#away
There are a few ways you could go about doing this, but if you're writing up a SmartApp just for your own uses, I'd suggest piggybacking off of one of the existing device types for the Nest on SmartThings. As a quick example, I'll use the one that I use:
https://github.com/bmmiller/device-type.nest/blob/master/nest.devicetype.groovy
After line 96, this is to expose the status to any SmartApp you may write:
attribute "temperatureUnit", "string"
attribute "humiditySetpoint", "number"
attribute "autoAwayStatus", "number" // New Line
Now, you'll want to take care of getting the data in the existing poll() method, currently starting at line 459.
After line 480, to update the attribute
sendEvent(name: 'humidity', value: humidity)
sendEvent(name: 'humiditySetpoint', value: humiditySetpoint, unit: Humidity)
sendEvent(name: 'thermostatFanMode', value: fanMode)
sendEvent(name: 'thermostatMode', value: temperatureType)
sendEvent(name: 'autoAwayStatus', value: data.shared.auto_away) // New Line
This will expose a numerical value for the auto_away status.
-1 = Auto Away Not Enabled
0 = Auto Away Off
1 = Auto Away On
Then, in your SmartApp you write, where you include an input of type thermostat like this:
section("Choose thermostat... ") {
input "thermostat", "capability.thermostat"
}
You will be able to access the Auto Away status by referring to
thermostat.autoAwayStatus
From anywhere in your code where you can do something like
if (thermostat.autoAwayStatus == 1) {
// Turn off everything
}

How do I define Sequelize.STRING length?

I want to define a length of a datatype in sequelize.
There is my source code :
var Profile = sequelize.define('profile', {
public_id: Sequelize.STRING,
label: Sequelize.STRING
})
It create a table profiles with a public_id with a datatype varchar(255).
I would like to define a public_id with varchar(32).
I searched on the doc and the stack but couldn't find any answer...
How can I do that please ?
As it is mentioned in the documentation, use:
Sequelize.STRING(32)
First, I think you need to rethink your design just a little bit. The basic point is that length constraints should be meaningful, not just there to save space. PostgreSQL does not store 'A'::varchar(10) any differently than it does 'A'::text (both are stored as variable length text strings, only as long as the value stored, along with a length specifier and some other metadata), so you should use the longest size that can work for you, and use the lengths for substantive enforcement rather than to save space. When in doubt, don't constrain. When you need to make sure it fits on a mailing label, constrain appropriately.
Secondly Dankohn's answer above:
var Profile = sequelize.define('PublicID', {
public_id: {
validate: { len: [0,32] })
is how you would then add such enforcement to the front-end. Again, such enforcement should be based on what you know you need, not just what seems like a good idea at the time, and while it is generally easier to relax constraints than tighten them, for string length, it's really a no-brainer to do things the other way.
As for using such in other applications, you'd probably want to look up the constraint info in the system catalogs, which gets you into sort of advanced territory.

Resources