code
stringlengths
73
34.1k
label
stringclasses
1 value
public IntervalFrequency getRefreshFrequency() { switch (mRefreshInterval) { case REALTIME_REFRESH_INTERVAL: return IntervalFrequency.REALTIME; case HIGH_REFRESH_INTERVAL: return IntervalFrequency.HIGH; case LOW_REFRESH_INTERVAL: ...
java
private float[] generateParticleVelocities() { float velocities[] = new float[mEmitRate * 3]; for ( int i = 0; i < mEmitRate * 3; i +=3 ) { Vector3f nexVel = getNextVelocity(); velocities[i] = nexVel.x; velocities[i+1] = nexVel.y; velocities[i+...
java
private float[] generateParticleTimeStamps(float totalTime) { float timeStamps[] = new float[mEmitRate * 2]; for ( int i = 0; i < mEmitRate * 2; i +=2 ) { timeStamps[i] = totalTime + mRandom.nextFloat(); timeStamps[i + 1] = 0; } return timeStamps; ...
java
public static WidgetLib init(GVRContext gvrContext, String customPropertiesAsset) throws InterruptedException, JSONException, NoSuchMethodException { if (mInstance == null) { // Constructor sets mInstance to ensure the initialization order new WidgetLib(gvrContext, customProp...
java
public void BuildInteractiveObjectFromAnchor(Sensor anchorSensor, String anchorDestination) { InteractiveObject interactiveObject = new InteractiveObject(); interactiveObject.setSensor(anchorSensor, anchorDestination); interactiveObjects.add(interactiveObject); }
java
private void RunScript(InteractiveObject interactiveObject, String functionName, Object[] parameters) { boolean complete = false; if ( V8JavaScriptEngine) { GVRJavascriptV8File gvrJavascriptV8File = interactiveObject.getScriptObject().getGVRJavascriptV8File(); String paramString ...
java
public Quaternionf ConvertDirectionalVectorToQuaternion(Vector3f d) { d.negate(); Quaternionf q = new Quaternionf(); // check for exception condition if ((d.x == 0) && (d.z == 0)) { // exception condition if direction is (0,y,0): // straight up, straight down or a...
java
public static void count() { long duration = SystemClock.uptimeMillis() - startTime; float avgFPS = sumFrames / (duration / 1000f); Log.v("FPSCounter", "total frames = %d, total elapsed time = %d ms, average fps = %f", sumFrames, duration, avgFPS); }
java
public static void startCheck(String extra) { startCheckTime = System.currentTimeMillis(); nextCheckTime = startCheckTime; Log.d(Log.SUBSYSTEM.TRACING, "FPSCounter" , "[%d] startCheck %s", startCheckTime, extra); }
java
public static void timeCheck(String extra) { if (startCheckTime > 0) { long now = System.currentTimeMillis(); long diff = now - nextCheckTime; nextCheckTime = now; Log.d(Log.SUBSYSTEM.TRACING, "FPSCounter", "[%d, %d] timeCheck: %s", now, diff, extra); } ...
java
public void animate(GVRHybridObject object, float animationTime) { GVRMeshMorph morph = (GVRMeshMorph) mTarget; mKeyInterpolator.animate(animationTime * mDuration, mCurrentValues); morph.setWeights(mCurrentValues); }
java
public synchronized void addRange(final float range, final GVRSceneObject sceneObject) { if (null == sceneObject) { throw new IllegalArgumentException("sceneObject must be specified!"); } if (range < 0) { throw new IllegalArgumentException("range cannot be negative");...
java
public void onDrawFrame(float frameTime) { final GVRSceneObject owner = getOwnerObject(); if (owner == null) { return; } final int size = mRanges.size(); final GVRTransform t = getGVRContext().getMainScene().getMainCameraRig().getCenterCamera().getTransform(); ...
java
public static Shell createConsoleShell(String prompt, String appName, Object... handlers) { ConsoleIO io = new ConsoleIO(); List<String> path = new ArrayList<String>(1); path.add(prompt); MultiMap<String, Object> modifAuxHandlers = new ArrayHashMultiMap<String, Object>(); modif...
java
public static Shell createConsoleShell(String prompt, String appName, Object mainHandler) { return createConsoleShell(prompt, appName, mainHandler, new EmptyMultiMap<String, Object>()); }
java
public static Shell createSubshell(String pathElement, Shell parent, String appName, Object mainHandler, MultiMap<String, Object> auxHandlers) { List<String> newPath = new ArrayList<String>(parent.getPath()); newPath.add(pathElement); Shell subshell = new Shell(parent.getSettings()...
java
public static Shell createSubshell(String pathElement, Shell parent, String appName, Object mainHandler) { return createSubshell(pathElement, parent, appName, mainHandler, new EmptyMultiMap<String, Object>()); }
java
public void animate(float animationTime, Matrix4f mat) { mRotInterpolator.animate(animationTime, mRotKey); mPosInterpolator.animate(animationTime, mPosKey); mSclInterpolator.animate(animationTime, mScaleKey); mat.translationRotateScale(mPosKey[0], mPosKey[1], mPosKey[2], mRotKey[0], ...
java
public void setAmbientIntensity(float r, float g, float b, float a) { setVec4("ambient_intensity", r, g, b, a); }
java
public void setDiffuseIntensity(float r, float g, float b, float a) { setVec4("diffuse_intensity", r, g, b, a); }
java
public void setSpecularIntensity(float r, float g, float b, float a) { setVec4("specular_intensity", r, g, b, a); }
java
private float getQuaternionW(float x, float y, float z) { return (float) Math.cos(Math.asin(Math.sqrt(x * x + y * y + z * z))); }
java
public void shutdown() { debugConnection = null; shuttingDown = true; try { if (serverSocket != null) { serverSocket.close(); } } catch (IOException e) { e.printStackTrace(); } }
java
@Override public void run() { ExecutorService executorService = Executors.newFixedThreadPool(maxClients); try { serverSocket = new ServerSocket(port, maxClients); while (!shuttingDown) { try { Socket socket = serverSocket.accept(); ...
java
public synchronized void removeAllSceneObjects() { final GVRCameraRig rig = getMainCameraRig(); final GVRSceneObject head = rig.getOwnerObject(); rig.removeAllChildren(); NativeScene.removeAllSceneObjects(getNative()); for (final GVRSceneObject child : mSceneRoot.getChildren()) ...
java
public void setPickRay(float ox, float oy, float oz, float dx, float dy, float dz) { synchronized (this) { mRayOrigin.x = ox; mRayOrigin.y = oy; mRayOrigin.z = oz; mRayDirection.x = dx; mRayDirection.y = dy; mRayDirection.z = dz...
java
public void onDrawFrame(float frameTime) { if (isEnabled() && (mScene != null) && mPickEventLock.tryLock()) { // Don't call if we are in the middle of processing another pick try { doPick(); } finally { ...
java
public void processPick(boolean touched, MotionEvent event) { mPickEventLock.lock(); mTouched = touched; mMotionEvent = event; doPick(); mPickEventLock.unlock(); }
java
protected void propagateOnNoPick(GVRPicker picker) { if (mEventOptions.contains(EventOptions.SEND_PICK_EVENTS)) { if (mEventOptions.contains(EventOptions.SEND_TO_LISTENERS)) { getGVRContext().getEventManager().sendEvent(this, IPickEvents.class, "onNoPick", pic...
java
protected void propagateOnMotionOutside(MotionEvent event) { if (mEventOptions.contains(EventOptions.SEND_TOUCH_EVENTS)) { if (mEventOptions.contains(EventOptions.SEND_TO_LISTENERS)) { getGVRContext().getEventManager().sendEvent(this, ITouchEvents.class, "onMo...
java
protected void propagateOnEnter(GVRPickedObject hit) { GVRSceneObject hitObject = hit.getHitObject(); GVREventManager eventManager = getGVRContext().getEventManager(); if (mEventOptions.contains(EventOptions.SEND_TOUCH_EVENTS)) { if (mEventOptions.contains(EventOptions.SE...
java
protected void propagateOnTouch(GVRPickedObject hit) { if (mEventOptions.contains(EventOptions.SEND_TOUCH_EVENTS)) { GVREventManager eventManager = getGVRContext().getEventManager(); GVRSceneObject hitObject = hit.getHitObject(); if (mEventOptions.contains(EventOp...
java
protected GVRPickedObject findCollider(GVRPickedObject[] pickList, GVRCollider findme) { if (pickList == null) { return null; } for (GVRPickedObject hit : pickList) { if ((hit != null) && (hit.hitCollider == findme)) { retur...
java
public static final GVRPickedObject[] pickObjects(GVRScene scene, float ox, float oy, float oz, float dx, float dy, float dz) { sFindObjectsLock.lock(); try { final GVRPickedObject[] result = NativePicker.pickObjects(scene.getNative(), 0L...
java
static GVRPickedObject makeHitMesh(long colliderPointer, float distance, float hitx, float hity, float hitz, int faceIndex, float barycentricx, float barycentricy, float barycentricz, float texu, float texv, float normalx, float normaly, float norma...
java
public static List<GVRAtlasInformation> loadAtlasInformation(InputStream ins) { try { int size = ins.available(); byte[] buffer = new byte[size]; ins.read(buffer); return loadAtlasInformation(new JSONArray(new String(buffer, "UTF-8"))); } catch (JSONExce...
java
public void setSpeed(float newValue) { if (newValue < 0) newValue = 0; this.pitch.setValue( newValue ); this.speed.setValue( newValue ); }
java
public String getUniformDescriptor(GVRContext ctx) { if (mShaderTemplate == null) { mShaderTemplate = makeTemplate(ID, ctx); ctx.getShaderManager().addShaderID(this); } return mShaderTemplate.getUniformDescriptor(); }
java
public GVRShader getTemplate(GVRContext ctx) { if (mShaderTemplate == null) { mShaderTemplate = makeTemplate(ID, ctx); ctx.getShaderManager().addShaderID(this); } return mShaderTemplate; }
java
GVRShader makeTemplate(Class<? extends GVRShader> id, GVRContext ctx) { try { Constructor<? extends GVRShader> maker = id.getDeclaredConstructor(GVRContext.class); return maker.newInstance(ctx); } catch (NoSuchMethodException | IllegalAccessException | Instant...
java
public void start(GVRAccessibilitySpeechListener speechListener) { mTts.setSpeechListener(speechListener); mTts.getSpeechRecognizer().startListening(mTts.getSpeechRecognizerIntent()); }
java
public void setVertexBuffer(GVRVertexBuffer vbuf) { if (vbuf == null) { throw new IllegalArgumentException("Vertex buffer cannot be null"); } mVertices = vbuf; NativeMesh.setVertexBuffer(getNative(), vbuf.getNative()); }
java
public void setIndexBuffer(GVRIndexBuffer ibuf) { mIndices = ibuf; NativeMesh.setIndexBuffer(getNative(), (ibuf != null) ? ibuf.getNative() : 0L); }
java
public static void rebuild(final MODE newMode) { if (mode != newMode) { mode = newMode; TYPE type; switch (mode) { case DEBUG: type = TYPE.ANDROID; Log.startFullLog(); break; case DEVELOPER: ...
java
public static int e(ISubsystem subsystem, String tag, String msg) { return isEnabled(subsystem) ? currentLog.e(tag, getMsg(subsystem,msg)) : 0; }
java
public static void d(ISubsystem subsystem, String tag, String pattern, Object... parameters) { if (!isEnabled(subsystem)) return; d(subsystem, tag, format(pattern, parameters)); }
java
private static void deleteOldAndEmptyFiles() { File dir = LOG_FILE_DIR; if (dir.exists()) { File[] files = dir.listFiles(); for (File f : files) { if (f.length() == 0 || f.lastModified() + MAXFILEAGE < System.curren...
java
public boolean load(GVRScene scene) { GVRAssetLoader loader = getGVRContext().getAssetLoader(); if (scene == null) { scene = getGVRContext().getMainScene(); } if (mReplaceScene) { loader.loadScene(getOwnerObject(), mVolume, mImportSettings, sc...
java
public void load(IAssetEvents handler) { GVRAssetLoader loader = getGVRContext().getAssetLoader(); if (mReplaceScene) { loader.loadScene(getOwnerObject(), mVolume, mImportSettings, getGVRContext().getMainScene(), handler); } else { loader.load...
java
public String[] parseMFString(String mfString) { Vector<String> strings = new Vector<String>(); StringReader sr = new StringReader(mfString); StreamTokenizer st = new StreamTokenizer(sr); st.quoteChar('"'); st.quoteChar('\''); String[] mfStrings = null; int toke...
java
private static Point getScreenSize(Context context, Point p) { if (p == null) { p = new Point(); } WindowManager windowManager = (WindowManager) context .getSystemService(Context.WINDOW_SERVICE); Display display = windowManager.getDefaultDisplay(); dis...
java
public float get(int row, int col) { if (row < 0 || row > 3) { throw new IndexOutOfBoundsException("Index: " + row + ", Size: 4"); } if (col < 0 || col > 3) { throw new IndexOutOfBoundsException("Index: " + col + ", Size: 4"); } return m_data[row * 4 + co...
java
public PeriodicEvent runAfter(Runnable task, float delay) { validateDelay(delay); return new Event(task, delay); }
java
public PeriodicEvent runEvery(Runnable task, float delay, float period) { return runEvery(task, delay, period, null); }
java
public PeriodicEvent runEvery(Runnable task, float delay, float period, int repetitions) { if (repetitions < 1) { return null; } else if (repetitions == 1) { // Better to burn a handful of CPU cycles than to churn memory by // creating a new callback ...
java
public PeriodicEvent runEvery(Runnable task, float delay, float period, KeepRunning callback) { validateDelay(delay); validatePeriod(period); return new Event(task, delay, period, callback); }
java
@SuppressWarnings("unchecked") public <V3, M4, C, N, Q> N getSceneRoot(AiWrapperProvider<V3, M4, C, N, Q> wrapperProvider) { return (N) m_sceneRoot; }
java
public void enableClipRegion() { if (mClippingEnabled) { Log.w(TAG, "Clipping has been enabled already for %s!", getName()); return; } Log.d(Log.SUBSYSTEM.WIDGET, TAG, "enableClipping for %s [%f, %f, %f]", getName(), getViewPortWidth(), getViewPortHeight()...
java
public float getLayoutSize(final Layout.Axis axis) { float size = 0; for (Layout layout : mLayouts) { size = Math.max(size, layout.getSize(axis)); } Log.d(Log.SUBSYSTEM.LAYOUT, TAG, "getLayoutSize [%s] axis [%s] size [%f]", getName(), axis, size); return size; }
java
public float getBoundsWidth() { if (mSceneObject != null) { GVRSceneObject.BoundingVolume v = mSceneObject.getBoundingVolume(); return v.maxCorner.x - v.minCorner.x; } return 0f; }
java
public float getBoundsHeight(){ if (mSceneObject != null) { GVRSceneObject.BoundingVolume v = mSceneObject.getBoundingVolume(); return v.maxCorner.y - v.minCorner.y; } return 0f; }
java
public float getBoundsDepth() { if (mSceneObject != null) { GVRSceneObject.BoundingVolume v = mSceneObject.getBoundingVolume(); return v.maxCorner.z - v.minCorner.z; } return 0f; }
java
public void rotateWithPivot(float w, float x, float y, float z, float pivotX, float pivotY, float pivotZ) { getTransform().rotateWithPivot(w, x, y, z, pivotX, pivotY, pivotZ); if (mTransformCache.rotateWithPivot(w, x, y, z, pivotX, pivotY, pivotZ)) { onTransformChanged(); ...
java
public boolean setVisibility(final Visibility visibility) { if (visibility != mVisibility) { Log.d(Log.SUBSYSTEM.WIDGET, TAG, "setVisibility(%s) for %s", visibility, getName()); updateVisibility(visibility); mVisibility = visibility; return true; } ...
java
public boolean setViewPortVisibility(final ViewPortVisibility viewportVisibility) { boolean visibilityIsChanged = viewportVisibility != mIsVisibleInViewPort; if (visibilityIsChanged) { Visibility visibility = mVisibility; switch(viewportVisibility) { case FULLY_V...
java
public Widget findChildByName(final String name) { final List<Widget> groups = new ArrayList<>(); groups.add(this); return findChildByNameInAllGroups(name, groups); }
java
protected final boolean isGLThread() { final Thread glThread = sGLThread.get(); return glThread != null && glThread.equals(Thread.currentThread()); }
java
protected void update(float scale) { // Updates only when the plane is in the scene GVRSceneObject owner = getOwnerObject(); if ((owner != null) && isEnabled() && owner.isEnabled()) { convertFromARtoVRSpace(scale); } }
java
public void setCastShadow(boolean enableFlag) { GVRSceneObject owner = getOwnerObject(); if (owner != null) { GVRShadowMap shadowMap = (GVRShadowMap) getComponent(GVRRenderTarget.getComponentType()); if (enableFlag) { if (shadowMap != null...
java
public synchronized void delete(String name) { if (isEmpty(name)) { indexedProps.remove(name); } else { synchronized (context) { int scope = context.getAttributesScope(name); if (scope != -1) { context.removeAttribute(name, scop...
java
public synchronized Object[] getIds() { String[] keys = getAllKeys(); int size = keys.length + indexedProps.size(); Object[] res = new Object[size]; System.arraycopy(keys, 0, res, 0, keys.length); int i = keys.length; // now add all indexed properties for (Object ...
java
public boolean hasInstance(Scriptable instance) { // Default for JS objects (other than Function) is to do prototype // chasing. Scriptable proto = instance.getPrototype(); while (proto != null) { if (proto.equals(this)) return true; proto = proto.getPrototype(); ...
java
public void setLoop(boolean doLoop, GVRContext gvrContext) { if (this.loop != doLoop ) { // a change in the loop for (GVRNodeAnimation gvrKeyFrameAnimation : gvrKeyFrameAnimations) { if (doLoop) gvrKeyFrameAnimation.setRepeatMode(GVRRepeatMode.REPEATED); e...
java
public void setCycleInterval(float newCycleInterval) { if ( (this.cycleInterval != newCycleInterval) && (newCycleInterval > 0) ) { for (GVRNodeAnimation gvrKeyFrameAnimation : gvrKeyFrameAnimations) { //TODO Cannot easily change the GVRAnimation's GVRChannel once set. } ...
java
public ExecutionChain setErrorCallback(ErrorCallback callback) { if (state.get() == State.RUNNING) { throw new IllegalStateException( "Invalid while ExecutionChain is running"); } errorCallback = callback; return this; }
java
public void execute() { State currentState = state.getAndSet(State.RUNNING); if (currentState == State.RUNNING) { throw new IllegalStateException( "ExecutionChain is already running!"); } executeRunnable = new ExecuteRunnable(); }
java
public boolean isHomeKeyPresent() { final GVRApplication application = mApplication.get(); if (null != application) { final String model = getHmtModel(); if (null != model && model.contains("R323")) { return true; } } return false; ...
java
public void addAuxHandler(Object handler, String prefix) { if (handler == null) { throw new NullPointerException(); } auxHandlers.put(prefix, handler); allHandlers.add(handler); addDeclaredMethods(handler, prefix); inputConverter.addDeclaredConverters(handler...
java
public void commandLoop() throws IOException { for (Object handler : allHandlers) { if (handler instanceof ShellManageable) { ((ShellManageable)handler).cliEnterLoop(); } } output.output(appName, outputConverter); String command = ""; while...
java
@Override public void addVariable(String varName, Object value) { synchronized (mGlobalVariables) { mGlobalVariables.put(varName, value); } refreshGlobalBindings(); }
java
@Override public void attachScriptFile(IScriptable target, IScriptFile scriptFile) { mScriptMap.put(target, scriptFile); scriptFile.invokeFunction("onAttach", new Object[] { target }); }
java
@Override public void detachScriptFile(IScriptable target) { IScriptFile scriptFile = mScriptMap.remove(target); if (scriptFile != null) { scriptFile.invokeFunction("onDetach", new Object[] { target }); } }
java
public void bindScriptBundleToScene(GVRScriptBundle scriptBundle, GVRScene scene) throws IOException, GVRScriptException { for (GVRSceneObject sceneObject : scene.getSceneObjects()) { bindBundleToSceneObject(scriptBundle, sceneObject); } }
java
public void bindBundleToSceneObject(GVRScriptBundle scriptBundle, GVRSceneObject rootSceneObject) throws IOException, GVRScriptException { bindHelper(scriptBundle, rootSceneObject, BIND_MASK_SCENE_OBJECTS); }
java
protected void bindHelper(GVRScriptBundle scriptBundle, GVRSceneObject rootSceneObject, int bindMask) throws IOException, GVRScriptException { for (GVRScriptBindingEntry entry : scriptBundle.file.binding) { GVRAndroidResource rc; if (entry.volumeType == null || entry.volu...
java
private long doMemoryManagementAndPerFrameCallbacks() { long currentTime = GVRTime.getCurrentTime(); mFrameTime = (currentTime - mPreviousTimeNanos) / 1e9f; mPreviousTimeNanos = currentTime; /* * Without the sensor data, can't draw a scene properly. */ if (!(mS...
java
protected void capture3DScreenShot(GVRRenderTarget renderTarget, boolean isMultiview) { if (mScreenshot3DCallback == null) { return; } final Bitmap[] bitmaps = new Bitmap[6]; renderSixCamerasAndReadback(mMainScene.getMainCameraRig(), bitmaps, renderTarget, isMultiview); ...
java
private void captureEye(GVRScreenshotCallback callback, GVRRenderTarget renderTarget, GVRViewManager.EYE eye, boolean useMultiview) { if (null == callback) { return; } readRenderResult(renderTarget,eye,useMultiview); returnScreenshotToCaller(callback, mReadbackBufferWidth, mR...
java
protected void captureCenterEye(GVRRenderTarget renderTarget, boolean isMultiview) { if (mScreenshotCenterCallback == null) { return; } // TODO: when we will use multithreading, create new camera using centercamera as we are adding posteffects into it final GVRCamera centerC...
java
public boolean runOnMainThreadNext(Runnable r) { assert handler != null; if (!sanityCheck("runOnMainThreadNext " + r)) { return false; } return handler.post(r); }
java
private void showSettingsMenu(final Cursor cursor) { Log.d(TAG, "showSettingsMenu"); enableSettingsCursor(cursor); context.runOnGlThread(new Runnable() { @Override public void run() { new SettingsView(context, scene, CursorManager.this, ...
java
private void updateCursorsInScene(GVRScene scene, boolean add) { synchronized (mCursors) { for (Cursor cursor : mCursors) { if (cursor.isActive()) { if (add) { addCursorToScene(cursor); } else { r...
java
public List<Widget> getAllViews() { List<Widget> views = new ArrayList<>(); for (Widget child: mContent.getChildren()) { Widget item = ((ListItemHostWidget) child).getGuest(); if (item != null) { views.add(item); } } return views; ...
java
public boolean clearSelection(boolean requestLayout) { Log.d(Log.SUBSYSTEM.LAYOUT, TAG, "clearSelection [%d]", mSelectedItemsList.size()); boolean updateLayout = false; List<ListItemHostWidget> views = getAllHosts(); for (ListItemHostWidget host: views) { if (host.isSelecte...
java
public boolean updateSelectedItemsList(int dataIndex, boolean select) { boolean done = false; boolean contains = isSelected(dataIndex); if (select) { if (!contains) { if (!mMultiSelectionSupported) { clearSelection(false); } ...
java
private void onScrollImpl(final Vector3Axis offset, final LayoutScroller.OnScrollListener listener) { if (!isScrolling()) { mScroller = new ScrollingProcessor(offset, listener); mScroller.scroll(); } }
java
protected void recycleChildren() { for (ListItemHostWidget host: getAllHosts()) { recycle(host); } mContent.onTransformChanged(); mContent.requestLayout(); }
java
private void onChangedImpl(final int preferableCenterPosition) { for (ListOnChangedListener listener: mOnChangedListeners) { listener.onChangedStart(this); } Log.d(Log.SUBSYSTEM.LAYOUT, TAG, "onChangedImpl(%s): items [%d] views [%d] mLayouts.size() = %d " + "...
java
static Shell createTerminalConsoleShell(String prompt, String appName, ShellCommandHandler mainHandler, InputStream input, OutputStream output) { try { PrintStream out = new PrintStream(output); // Build jline terminal jline.Terminal term = TerminalFactory.get();...
java
static Shell createTelnetConsoleShell(String prompt, String appName, ShellCommandHandler mainHandler, InputStream input, OutputStream output) { try { // Set up nvt4j; ignore the initial clear & reposition final nvt4j.impl.Terminal nvt4jTerminal = new nvt4j.impl.Terminal(input...
java